mobx
- Version 6.13.6
- Published
- 4.33 MB
- No dependencies
- MIT license
Install
npm i mobx
yarn add mobx
pnpm add mobx
Overview
Simple, scalable state management.
Index
Variables
Functions
- autorun()
- configure()
- createAtom()
- defineProperty()
- entries()
- extendObservable()
- FlowCancellationError()
- flowResult()
- get()
- getAtom()
- getDebugName()
- getDependencyTree()
- getObserverTree()
- has()
- intercept()
- isAction()
- isComputed()
- isComputedProp()
- isFlow()
- isFlowCancellationError()
- isObservable()
- isObservableArray()
- isObservableObject()
- isObservableProp()
- keys()
- makeAutoObservable()
- makeObservable()
- observe()
- onBecomeObserved()
- onBecomeUnobserved()
- onReactionError()
- ownKeys()
- reaction()
- remove()
- runInAction()
- set()
- spy()
- toJS()
- trace()
- transaction()
- untracked()
- values()
- when()
Classes
ObservableSet
- [$mobx]
- [Symbol.iterator]()
- [Symbol.toStringTag]
- add()
- atom_
- changeListeners_
- clear()
- dehancer
- delete()
- difference()
- enhancer_
- entries()
- forEach()
- has()
- intercept_()
- interceptors_
- intersection()
- isDisjointFrom()
- isSubsetOf()
- isSupersetOf()
- keys()
- name_
- observe_()
- replace()
- size
- symmetricDifference()
- toJSON()
- toString()
- union()
- values()
Interfaces
Type Aliases
Variables
variable $mobx
const $mobx: Symbol;
variable action
const action: IActionFactory;
variable comparer
const comparer: { identity: (a: any, b: any) => boolean; structural: (a: any, b: any) => boolean; default: (a: any, b: any) => boolean; shallow: (a: any, b: any) => boolean;};
variable computed
const computed: IComputedFactory;
Decorator for class properties: get value() { return expr; }. For legacy purposes also invokable as ES5 observable created:
computed(() => expr)
;
variable flow
const flow: Flow;
variable FlowCancellationError
const FlowCancellationError: typeof FlowCancellationError;
variable isBoxedObservable
const isBoxedObservable: (x: any) => x is IObservableValue<any>;
variable isObservableMap
var isObservableMap: (thing: any) => thing is ObservableMap<any, any>;
variable isObservableSet
var isObservableSet: (thing: any) => thing is ObservableSet<any>;
variable observable
var observable: IObservableFactory;
variable override
const override: Annotation & PropertyDecorator & ClassMethodDecorator<any, any>;
Functions
function autorun
autorun: ( view: (r: IReactionPublic) => any, opts?: IAutorunOptions) => IReactionDisposer;
Creates a named reactive view and keeps it alive, so that the view is always updated if one of the dependencies changes, even when the view is not further used by something else.
Parameter view
The reactive view
Returns
disposer function, which can be used to stop the view from being updated in the future.
function configure
configure: (options: { enforceActions?: 'never' | 'always' | 'observed'; computedRequiresReaction?: boolean; reactionRequiresObservable?: boolean; observableRequiresReaction?: boolean; isolateGlobalState?: boolean; disableErrorBoundaries?: boolean; safeDescriptors?: boolean; reactionScheduler?: (f: () => void) => void; useProxies?: 'always' | 'never' | 'ifavailable';}) => void;
function createAtom
createAtom: ( name: string, onBecomeObservedHandler?: () => void, onBecomeUnobservedHandler?: () => void) => IAtom;
function defineProperty
defineProperty: ( obj: Object, key: PropertyKey, descriptor: PropertyDescriptor) => boolean;
function entries
entries: { <K, T>(map: ObservableMap<K, T>): readonly [K, T][]; <T>(set: ObservableSet<T>): readonly [T, T][]; <T>(ar: IObservableArray<T>): readonly [number, T][]; <T = any>(obj: T): readonly [string, T extends object ? T[keyof T] : any][];};
function extendObservable
extendObservable: <A extends Object, B extends Object>( target: A, properties: B, annotations?: AnnotationsMap<B, never>, options?: CreateObservableOptions) => A & B;
function FlowCancellationError
FlowCancellationError: typeof FlowCancellationError;
function flowResult
flowResult: <T>( result: T) => T extends Generator<any, infer R, any> ? CancellablePromise<R> : T extends CancellablePromise<any> ? T : never;
function get
get: { <K, V>(obj: ObservableMap<K, V>, key: K): V; <T>(obj: IObservableArray<T>, index: number): T; <T extends Object>(obj: T, key: string): any;};
function getAtom
getAtom: (thing: any, property?: PropertyKey) => IDepTreeNode;
function getDebugName
getDebugName: (thing: any, property?: string) => string;
function getDependencyTree
getDependencyTree: (thing: any, property?: string) => IDependencyTree;
function getObserverTree
getObserverTree: (thing: any, property?: string) => IObserverTree;
function has
has: { <K>(obj: ObservableMap<K, any>, key: K): boolean; <T>(obj: ObservableSet<T>, key: T): boolean; <T>(obj: IObservableArray<T>, index: number): boolean; <T extends Object>(obj: T, key: string): boolean;};
function intercept
intercept: { <T>( value: IObservableValue<T>, handler: IInterceptor<IValueWillChange<T>> ): Lambda; <T>( observableArray: IObservableArray<T> | T[], handler: IInterceptor<IArrayWillChange<T> | IArrayWillSplice<T>> ): Lambda; <K, V>( observableMap: ObservableMap<K, V> | Map<K, V>, handler: IInterceptor<IMapWillChange<K, V>> ): Lambda; <V>( observableSet: ObservableSet<V> | Set<V>, handler: IInterceptor<ISetWillChange<V>> ): Lambda; <K, V>( observableMap: ObservableMap<K, V> | Map<K, V>, property: K, handler: IInterceptor<IValueWillChange<V>> ): Lambda; (object: object, handler: IInterceptor<IObjectWillChange<any>>): Lambda; <T extends object, K extends keyof T>( object: T, property: K, handler: IInterceptor<IValueWillChange<T[K]>> ): Lambda;};
function isAction
isAction: (thing: any) => boolean;
function isComputed
isComputed: (value: any) => boolean;
function isComputedProp
isComputedProp: (value: any, propName: PropertyKey) => boolean;
function isFlow
isFlow: (fn: any) => boolean;
function isFlowCancellationError
isFlowCancellationError: (error: Error) => boolean;
function isObservable
isObservable: (value: any) => boolean;
function isObservableArray
isObservableArray: (thing: any) => thing is IObservableArray<any>;
function isObservableObject
isObservableObject: (thing: any) => boolean;
function isObservableProp
isObservableProp: (value: any, propName: PropertyKey) => boolean;
function keys
keys: { <K>(map: ObservableMap<K, any>): readonly K[]; <T>(ar: IObservableArray<T>): readonly number[]; <T>(set: ObservableSet<T>): readonly T[]; <T extends Object>(obj: T): readonly PropertyKey[];};
function makeAutoObservable
makeAutoObservable: < T extends object, AdditionalKeys extends PropertyKey = never>( target: T, overrides?: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: MakeObservableOptions) => T;
function makeObservable
makeObservable: <T extends object, AdditionalKeys extends PropertyKey = never>( target: T, annotations?: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: MakeObservableOptions) => T;
function observe
observe: { <T>( value: IObservableValue<T> | IComputedValue<T>, listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean ): Lambda; <T>( observableArray: IObservableArray<T> | T[], listener: (change: IArrayDidChange<T>) => void, fireImmediately?: boolean ): Lambda; <V>( observableSet: ObservableSet<V> | Set<V>, listener: (change: ISetDidChange<V>) => void, fireImmediately?: boolean ): Lambda; <K, V>( observableMap: ObservableMap<K, V> | Map<K, V>, listener: (change: IMapDidChange<K, V>) => void, fireImmediately?: boolean ): Lambda; <K, V>( observableMap: ObservableMap<K, V> | Map<K, V>, property: K, listener: (change: IValueDidChange<V>) => void, fireImmediately?: boolean ): Lambda; ( object: Object, listener: (change: IObjectDidChange<any>) => void, fireImmediately?: boolean ): Lambda; <T, K extends keyof T>( object: T, property: K, listener: (change: IValueDidChange<T[K]>) => void, fireImmediately?: boolean ): Lambda;};
function onBecomeObserved
onBecomeObserved: { ( value: | IObservable | IObservableValue<any> | IObservableArray<any> | ObservableMap<any, any> | ObservableSet<any> | IComputedValue<any>, listener: Lambda ): Lambda; <K, V = any>( value: Object | ObservableMap<K, V>, property: K, listener: Lambda ): Lambda;};
function onBecomeUnobserved
onBecomeUnobserved: { ( value: | IObservable | IObservableValue<any> | IObservableArray<any> | ObservableMap<any, any> | ObservableSet<any> | IComputedValue<any>, listener: Lambda ): Lambda; <K, V = any>( value: Object | ObservableMap<K, V>, property: K, listener: Lambda ): Lambda;};
function onReactionError
onReactionError: ( handler: (error: any, derivation: IDerivation) => void) => Lambda;
function ownKeys
ownKeys: (obj: Object) => (string | symbol)[];
function reaction
reaction: <T, FireImmediately extends boolean = false>( expression: (r: IReactionPublic) => T, effect: ( arg: T, prev: FireImmediately extends true ? T | undefined : T, r: IReactionPublic ) => void, opts?: IReactionOptions<T, FireImmediately>) => IReactionDisposer;
function remove
remove: { <K, V>(obj: ObservableMap<K, V>, key: K): any; <T>(obj: ObservableSet<T>, key: T): any; <T>(obj: IObservableArray<T>, index: number): any; <T extends Object>(obj: T, key: string): any;};
function runInAction
runInAction: <T>(fn: () => T) => T;
function set
set: { <V>(obj: ObservableMap<PropertyKey, V>, values: { [key: string]: V }): any; <K, V>(obj: ObservableMap<K, V>, key: K, value: V): any; <T>(obj: ObservableSet<T>, value: T): any; <T>(obj: IObservableArray<T>, index: number, value: T): any; <T extends Object>(obj: T, values: { [key: string]: any }): any; <T extends Object>(obj: T, key: PropertyKey, value: any): any;};
function spy
spy: (listener: (change: SpyEvent) => void) => Lambda;
function toJS
toJS: <T>(source: T, options?: any) => T;
Recursively converts an observable to it's non-observable native counterpart. It does NOT recurse into non-observables, these are left as they are, even if they contain observables. Computed and other non-enumerable properties are completely ignored. Complex scenarios require custom solution, eg implementing
toJSON
or usingserializr
lib.
function trace
trace: { (thing?: any, prop?: string, enterBreakPoint?: boolean): void; (thing?: any, enterBreakPoint?: boolean): void; (enterBreakPoint?: boolean): void;};
function transaction
transaction: <T>(action: () => T, thisArg?: any) => T;
During a transaction no views are updated until the end of the transaction. The transaction will be run synchronously nonetheless.
Parameter action
a function that updates some reactive state
Returns
any value that was returned by the 'action' parameter.
function untracked
untracked: <T>(action: () => T) => T;
function values
values: { <K, T>(map: ObservableMap<K, T>): readonly T[]; <T>(set: ObservableSet<T>): readonly T[]; <T>(ar: IObservableArray<T>): readonly T[]; <T = any>(obj: T): readonly (T extends object ? T[keyof T] : any)[];};
function when
when: { (predicate: () => boolean, opts?: IWhenOptions): Promise<void> & { cancel(): void; }; ( predicate: () => boolean, effect: Lambda, opts?: IWhenOptions ): IReactionDisposer;};
Classes
class ObservableMap
class ObservableMap<K = any, V = any> implements Map<K, V>, IInterceptable<IMapWillChange<K, V>>, IListenable {}
constructor
constructor( initialData?: IObservableMapInitialValues<K, V>, enhancer_?: IEnhancer<V>, name_?: string);
property [$mobx]
[$mobx]: {};
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property changeListeners_
changeListeners_: any;
property data_
data_: Map<K, ObservableValue<V>>;
property dehancer
dehancer: any;
property enhancer_
enhancer_: IEnhancer<V>;
property hasMap_
hasMap_: Map<K, ObservableValue<boolean>>;
property interceptors_
interceptors_: any;
property keysAtom_
keysAtom_: IAtom;
property name_
name_: string;
property size
readonly size: number;
method [Symbol.iterator]
[Symbol.iterator]: () => MapIterator<IMapEntry<K, V>>;
method clear
clear: () => void;
method delete
delete: (key: K) => boolean;
method entries
entries: () => MapIterator<IMapEntry<K, V>>;
method forEach
forEach: ( callback: (value: V, key: K, object: Map<K, V>) => void, thisArg?: any) => void;
method get
get: (key: K) => V | undefined;
method has
has: (key: K) => boolean;
method intercept_
intercept_: (handler: IInterceptor<IMapWillChange<K, V>>) => Lambda;
method keys
keys: () => MapIterator<K>;
method merge
merge: (other?: IObservableMapInitialValues<K, V>) => ObservableMap<K, V>;
Merge another object into this object, returns this.
method observe_
observe_: ( listener: (changes: IMapDidChange<K, V>) => void, fireImmediately?: boolean) => Lambda;
Observes this object. Triggers for the events 'add', 'update' and 'delete'. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe for callback details
method replace
replace: (values: IObservableMapInitialValues<K, V>) => ObservableMap<K, V>;
method set
set: (key: K, value: V) => this;
method toJSON
toJSON: () => [K, V][];
method toString
toString: () => string;
method values
values: () => MapIterator<V>;
class ObservableSet
class ObservableSet<T = any> implements Set<T>, IInterceptable<ISetWillChange>, IListenable {}
constructor
constructor( initialData?: IObservableSetInitialValues<T>, enhancer?: IEnhancer<T>, name_?: string);
property [$mobx]
[$mobx]: {};
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property atom_
atom_: IAtom;
property changeListeners_
changeListeners_: any;
property dehancer
dehancer: any;
property enhancer_
enhancer_: (newV: any, oldV: any | undefined) => any;
property interceptors_
interceptors_: any;
property name_
name_: string;
property size
readonly size: number;
method [Symbol.iterator]
[Symbol.iterator]: () => SetIterator<T>;
method add
add: (value: T) => this;
method clear
clear: () => void;
method delete
delete: (value: T) => boolean;
method difference
difference: <U>(otherSet: ReadonlySetLike<U>) => Set<T>;
method entries
entries: () => SetIterator<T>;
method forEach
forEach: ( callbackFn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any) => void;
method has
has: (value: T) => boolean;
method intercept_
intercept_: (handler: IInterceptor<ISetWillChange<T>>) => Lambda;
method intersection
intersection: <U>(otherSet: ReadonlySetLike<U> | Set<U>) => Set<T & U>;
method isDisjointFrom
isDisjointFrom: (otherSet: ReadonlySetLike<unknown> | Set<unknown>) => boolean;
method isSubsetOf
isSubsetOf: (otherSet: ReadonlySetLike<unknown>) => boolean;
method isSupersetOf
isSupersetOf: (otherSet: ReadonlySetLike<unknown>) => boolean;
method keys
keys: () => SetIterator<T>;
method observe_
observe_: ( listener: (changes: ISetDidChange<T>) => void, fireImmediately?: boolean) => Lambda;
method replace
replace: ( other: ObservableSet<T> | IObservableSetInitialValues<T>) => ObservableSet<T>;
method symmetricDifference
symmetricDifference: <U>(otherSet: ReadonlySetLike<U> | Set<U>) => Set<T | U>;
method toJSON
toJSON: () => T[];
method toString
toString: () => string;
method union
union: <U>(otherSet: ReadonlySetLike<U> | Set<U>) => Set<T | U>;
method values
values: () => SetIterator<T>;
class Reaction
class Reaction implements IDerivation, IReactionPublic {}
constructor
constructor( name_?: string, onInvalidate_: () => void, errorHandler_?: (error: any, derivation: IDerivation) => void, requiresObservable_?: any);
property dependenciesState_
dependenciesState_: IDerivationState_;
property diffValue
diffValue: 0 | 1;
property isDisposed
isDisposed: boolean;
property isRunning
isRunning: boolean;
property isScheduled
isScheduled: boolean;
property isTracing_
isTracing_: TraceMode;
property isTrackPending
isTrackPending: boolean;
property name_
name_: string;
property newObserving_
newObserving_: IObservable[];
property observing_
observing_: IObservable[];
property requiresObservable_
requiresObservable_?: any;
property runId_
runId_: number;
property unboundDepsCount_
unboundDepsCount_: number;
method dispose
dispose: () => void;
method getDisposer_
getDisposer_: (abortSignal?: GenericAbortSignal) => IReactionDisposer;
method onBecomeStale_
onBecomeStale_: () => void;
method reportExceptionInDerivation_
reportExceptionInDerivation_: (error: any) => void;
method runReaction_
runReaction_: () => void;
internal, use schedule() if you intend to kick off a reaction
method schedule_
schedule_: () => void;
method toString
toString: () => string;
method trace
trace: (enterBreakPoint?: boolean) => void;
method track
track: (fn: () => void) => void;
Interfaces
interface IActionFactory
interface IActionFactory extends Annotation, PropertyDecorator, ClassMethodDecorator, ClassFieldDecorator {}
property bound
bound: Annotation & PropertyDecorator & ClassMethodDecorator & ClassFieldDecorator;
call signature
<T extends Function | undefined | null>(fn: T): T;
call signature
<T extends Function | undefined | null>(name: string, fn: T): T;
call signature
(customName: string): PropertyDecorator & Annotation & ClassMethodDecorator & ClassFieldDecorator;
interface IActionRunInfo
interface IActionRunInfo {}
property actionId_
actionId_: number;
property error_
error_?: any;
property notifySpy_
notifySpy_: boolean;
property parentActionId_
parentActionId_: number;
property prevAllowStateChanges_
prevAllowStateChanges_: boolean;
property prevAllowStateReads_
prevAllowStateReads_: boolean;
property prevDerivation_
prevDerivation_: IDerivation | null;
property runAsAction_
runAsAction_?: boolean;
property startTime_
startTime_: number;
interface IArraySplice
interface IArraySplice<T = any> extends IArrayBaseChange<T> {}
property added
added: T[];
property addedCount
addedCount: number;
property removed
removed: T[];
property removedCount
removedCount: number;
property type
type: 'splice';
interface IArrayUpdate
interface IArrayUpdate<T = any> extends IArrayBaseChange<T> {}
interface IArrayWillChange
interface IArrayWillChange<T = any> {}
interface IArrayWillSplice
interface IArrayWillSplice<T = any> {}
property added
added: T[];
property index
index: number;
property object
object: IObservableArray<T>;
property removedCount
removedCount: number;
property type
type: 'splice';
interface IAtom
interface IAtom extends IObservable {}
method reportChanged
reportChanged: () => void;
method reportObserved
reportObserved: () => boolean;
interface IAutorunOptions
interface IAutorunOptions {}
property delay
delay?: number;
property name
name?: string;
property onError
onError?: (error: any) => void;
property requiresObservable
requiresObservable?: boolean;
Experimental. Warns if the view doesn't track observables
property scheduler
scheduler?: (callback: () => void) => any;
property signal
signal?: GenericAbortSignal;
interface IComputedFactory
interface IComputedFactory extends Annotation, PropertyDecorator, ClassGetterDecorator {}
property struct
struct: Annotation & PropertyDecorator & ClassGetterDecorator;
call signature
<T>(options: IComputedValueOptions<T>): Annotation & PropertyDecorator & ClassGetterDecorator;
call signature
<T>(func: () => T, options?: IComputedValueOptions<T>): IComputedValue<T>;
interface IComputedValue
interface IComputedValue<T> {}
interface IComputedValueOptions
interface IComputedValueOptions<T> {}
interface IDependencyTree
interface IDependencyTree {}
property dependencies
dependencies?: IDependencyTree[];
property name
name: string;
interface IDepTreeNode
interface IDepTreeNode {}
property name_
name_: string;
property observing_
observing_?: IObservable[];
interface IEnhancer
interface IEnhancer<T> {}
call signature
(newValue: T, oldValue: T | undefined, name: string): T;
interface IEqualsComparer
interface IEqualsComparer<T> {}
call signature
(a: T, b: T): boolean;
interface IInterceptable
interface IInterceptable<T> {}
property interceptors_
interceptors_: IInterceptor<T>[] | undefined;
interface IKeyValueMap
interface IKeyValueMap<V = any> {}
index signature
[key: string]: V;
interface IListenable
interface IListenable {}
property changeListeners_
changeListeners_: Function[] | undefined;
interface IMapWillChange
interface IMapWillChange<K = any, V = any> {}
interface IObservable
interface IObservable extends IDepTreeNode {}
property diffValue
diffValue: number;
property isBeingObserved
isBeingObserved: boolean;
property isPendingUnobservation
isPendingUnobservation: boolean;
property lastAccessedBy_
lastAccessedBy_: number;
Id of the derivation *run* that last accessed this observable. If this id equals the *run* id of the current derivation, the dependency is already established
property lowestObserverState_
lowestObserverState_: IDerivationState_;
property observers_
observers_: Set<IDerivation>;
property onBOL
onBOL: Set<Lambda> | undefined;
property onBUOL
onBUOL: Set<Lambda> | undefined;
method onBO
onBO: () => void;
method onBUO
onBUO: () => void;
interface IObservableArray
interface IObservableArray<T = any> extends Array<T> {}
method clear
clear: () => T[];
method remove
remove: (value: T) => boolean;
method replace
replace: (newItems: T[]) => T[];
method spliceWithArray
spliceWithArray: (index: number, deleteCount?: number, newItems?: T[]) => T[];
method toJSON
toJSON: () => T[];
interface IObservableFactory
interface IObservableFactory extends Annotation, PropertyDecorator, ClassAccessorDecorator, ClassFieldDecorator {}
property array
array: <T = any>( initialValues?: T[], options?: CreateObservableOptions) => IObservableArray<T>;
property box
box: IObservableValueFactory;
property deep
deep: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator;
property map
map: <K = any, V = any>( initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions) => ObservableMap<K, V>;
property object
object: <T = any>( props: T, decorators?: AnnotationsMap<T, never>, options?: CreateObservableOptions) => T;
property ref
ref: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator;
Decorator that creates an observable that only observes the references, but doesn't try to turn the assigned value into an observable.ts.
property set
set: <T = any>( initialValues?: IObservableSetInitialValues<T>, options?: CreateObservableOptions) => ObservableSet<T>;
property shallow
shallow: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator;
Decorator that creates an observable converts its value (objects, maps or arrays) into a shallow observable structure
property struct
struct: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator;
call signature
<T = any>(value: T[], options?: CreateObservableOptions): IObservableArray<T>;
call signature
<T = any>(value: Set<T>, options?: CreateObservableOptions): ObservableSet<T>;
call signature
<K = any, V = any>( value: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
call signature
<T extends object>( value: T, decorators?: AnnotationsMap<T, never>, options?: CreateObservableOptions): T;
interface IObservableValue
interface IObservableValue<T> {}
interface IObserverTree
interface IObserverTree {}
interface IReactionDisposer
interface IReactionDisposer {}
property [$mobx]
[$mobx]: Reaction;
call signature
(): void;
interface IReactionPublic
interface IReactionPublic {}
Reactions are a special kind of derivations. Several things distinguishes them from normal reactive computations
1) They will always run, whether they are used by other computations or not. This means that they are very suitable for triggering side effects like logging, updating the DOM and making network requests. 2) They are not observable themselves 3) They will always run after any 'normal' derivations 4) They are allowed to change the state and thereby triggering themselves again, as long as they make sure the state propagates to a stable state in a reasonable amount of iterations.
The state machine of a Reaction is as follows:
1) after creating, the reaction should be started by calling
runReaction
or by scheduling it (see alsoautorun
) 2) theonInvalidate
handler should somehow result in a call tothis.track(someFunction)
3) all observables accessed insomeFunction
will be observed by this reaction. 4) as soon as some of the dependencies has changed the Reaction will be rescheduled for another run (after the current mutation or transaction).isScheduled
will yield true once a dependency is stale and during this period 5)onInvalidate
will be called, and we are back at step 1.
interface IValueWillChange
interface IValueWillChange<T> {}
interface IWhenOptions
interface IWhenOptions {}
interface Lambda
interface Lambda {}
property name
name?: string;
call signature
(): void;
Type Aliases
type AnnotationMapEntry
type AnnotationMapEntry = | Annotation | true /* follow the default decorator, usually deep */ | false;
type AnnotationsMap
type AnnotationsMap<T, AdditionalFields extends PropertyKey> = { [P in Exclude<keyof T, 'toString'>]?: AnnotationMapEntry;} & Record<AdditionalFields, AnnotationMapEntry>;
type CreateObservableOptions
type CreateObservableOptions = { name?: string; equals?: IEqualsComparer<any>; deep?: boolean; defaultDecorator?: Annotation; proxy?: boolean; autoBind?: boolean;};
type IArrayDidChange
type IArrayDidChange<T = any> = IArrayUpdate<T> | IArraySplice<T>;
type IInterceptor
type IInterceptor<T> = (change: T) => T | null;
type IMapDidChange
type IMapDidChange<K = any, V = any> = { observableKind: 'map'; debugObjectName: string;} & ( | { object: ObservableMap<K, V>; name: K; // actual the key or index, but this is based on the ancient .observe proposal for consistency type: 'update'; newValue: V; oldValue: V; } | { object: ObservableMap<K, V>; name: K; type: 'add'; newValue: V; } | { object: ObservableMap<K, V>; name: K; type: 'delete'; oldValue: V; });
type IMapEntries
type IMapEntries<K = any, V = any> = IMapEntry<K, V>[];
type IMapEntry
type IMapEntry<K = any, V = any> = [K, V];
type IObjectDidChange
type IObjectDidChange<T = any> = { observableKind: 'object'; name: PropertyKey; object: T; debugObjectName: string;} & ( | { type: 'add'; newValue: any; } | { type: 'update'; oldValue: any; newValue: any; } | { type: 'remove'; oldValue: any; });
type IObjectWillChange
type IObjectWillChange<T = any> = | { object: T; type: 'update' | 'add'; name: PropertyKey; newValue: any; } | { object: T; type: 'remove'; name: PropertyKey; };
type IObservableMapInitialValues
type IObservableMapInitialValues<K = any, V = any> = | IMapEntries<K, V> | IReadonlyMapEntries<K, V> | IKeyValueMap<V> | Map<K, V>;
type IObservableSetInitialValues
type IObservableSetInitialValues<T> = Set<T> | readonly T[];
type IReactionOptions
type IReactionOptions<T, FireImmediately extends boolean> = IAutorunOptions & { fireImmediately?: FireImmediately; equals?: IEqualsComparer<T>;};
type ISetDidChange
type ISetDidChange<T = any> = | { object: ObservableSet<T>; observableKind: 'set'; debugObjectName: string; type: 'add'; newValue: T; } | { object: ObservableSet<T>; observableKind: 'set'; debugObjectName: string; type: 'delete'; oldValue: T; };
type ISetWillChange
type ISetWillChange<T = any> = | { type: 'delete'; object: ObservableSet<T>; oldValue: T; } | { type: 'add'; object: ObservableSet<T>; newValue: T; };
type IValueDidChange
type IValueDidChange<T = any> = { type: 'update'; observableKind: 'value'; object: IObservableValue<T>; debugObjectName: string; newValue: T; oldValue: T | undefined;};
Package Files (40)
- src/api/action.ts
- src/api/annotation.ts
- src/api/autorun.ts
- src/api/become-observed.ts
- src/api/computed.ts
- src/api/configure.ts
- src/api/extendobservable.ts
- src/api/extras.ts
- src/api/flow.ts
- src/api/intercept.ts
- src/api/iscomputed.ts
- src/api/isobservable.ts
- src/api/makeObservable.ts
- src/api/object-api.ts
- src/api/observable.ts
- src/api/observe.ts
- src/api/tojs.ts
- src/api/trace.ts
- src/api/transaction.ts
- src/api/when.ts
- src/core/action.ts
- src/core/atom.ts
- src/core/computedvalue.ts
- src/core/derivation.ts
- src/core/observable.ts
- src/core/reaction.ts
- src/core/spy.ts
- src/mobx.ts
- src/types/intercept-utils.ts
- src/types/listen-utils.ts
- src/types/modifiers.ts
- src/types/observablearray.ts
- src/types/observablemap.ts
- src/types/observableobject.ts
- src/types/observableset.ts
- src/types/observablevalue.ts
- src/types/overrideannotation.ts
- src/types/type-utils.ts
- src/utils/comparer.ts
- src/utils/utils.ts
Dependencies (0)
No dependencies.
Dev Dependencies (9)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/mobx
.
- Markdown[](https://www.jsdocs.io/package/mobx)
- HTML<a href="https://www.jsdocs.io/package/mobx"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 9047 ms. - Missing or incorrect documentation? Open an issue for this package.