Skip to content

Commit

Permalink
Fixed the ReactionSpec type fix (#3540)
Browse files Browse the repository at this point in the history
* Fixed the ReactionSpec type fix

* ReactionSpec back to interface
  • Loading branch information
jskupsik authored Dec 1, 2023
1 parent f30bbe7 commit 5a729ef
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/HoistBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ export abstract class HoistBase {
addReaction(...specs: ReactionSpec<any>[]): IReactionDisposer | IReactionDisposer[] {
const disposers = specs.map(s => {
if (!s) return null;
let {track, when, run, debounce, ...opts} = s;
let {track, when, run, debounce, ...rest} = s;
throwIf(
(track && when) || (!track && !when),
"Must specify either 'track' or 'when' in addReaction."
);
opts = parseReactionOptions(opts);
const opts = parseReactionOptions(rest);
run = bindAndDebounce(this, run, debounce);

const disposer = track ? mobxReaction(track, run, opts) : mobxWhen(when, run, opts);
Expand Down Expand Up @@ -293,7 +293,7 @@ export abstract class HoistBase {
/**
* Object containing options accepted by MobX 'reaction' API as well as arguments below.
*/
export type ReactionSpec<T = any> = IReactionOptions<T, any> & {
export interface ReactionSpec<T = any> extends Omit<IReactionOptions<T, any>, 'equals'> {
/**
* Function returning data to observe - first arg to the underlying reaction() call.
* Specify this or `when`.
Expand All @@ -314,7 +314,7 @@ export type ReactionSpec<T = any> = IReactionOptions<T, any> & {

/** Specify a default from {@link comparer} or a custom comparer function. */
equals?: keyof typeof comparer | IEqualsComparer<T>;
};
}

/**
* Object containing options accepted by MobX 'autorun' API as well as arguments below.
Expand Down

0 comments on commit 5a729ef

Please sign in to comment.