Skip to content

unwatch

Annotation for unwatching changes to a property and a getter

When used as an annotation:

  • Combine with @observable, @computed or @nested (and their variants) to stop watching changes.
  • You cannot re-enable watching once @unwatch is specified.

When used as a function:

  • Runs a piece of code without changes being detected by Watcher.
    unwatch(() => (model.field = "value"));
  • Warning: When used inside a transaction, it only becomes 'watching' when the outermost transaction completes.
    runInAction(() => {
    unwatch(() => {
    // isWatching === false
    });
    // isWatching === FALSE <-- already in a transaction
    unwatch(() => {
    // isWatching === false
    });
    });
    // isWatching === TRUE

unwatch(action): void

Defined in: watcher.ts:97

() => void

void

unwatch(target, propertyKey): void

Defined in: watcher.ts:97

object

string | symbol

void

unwatch(value, context): void | ((this: object) => any)

Defined in: watcher.ts:97

(this: object) => any

ClassGetterDecoratorContext

void | ((this: object) => any)

unwatch(value, context): void | ClassAccessorDecoratorResult<object, any>

Defined in: watcher.ts:97

ClassAccessorDecoratorTarget<object, any>

ClassAccessorDecoratorContext

void | ClassAccessorDecoratorResult<object, any>

unwatch(value, context): any

Defined in: watcher.ts:97

undefined

ClassFieldDecoratorContext<object, any>

any