Skip to content

watch

Annotation for watching changes to a property and a getter

@watch by default unwraps boxed observables, arrays, sets, and maps — meaning it uses shallow comparison. If you don't want this behavior, use @watch.ref instead.

  • @observable and @computed (and their variants) are automatically assumed to be @watched,
    unless @unwatch or @unwatch.ref is specified.
  • @nested (and its variants) are considered @watched unless @unwatch is specified.
  • If @watch and @watch.ref are specified for the same key (in the same inheritance chain),
    the last annotation prevails.

watch(target, propertyKey): void

Defined in: watcher.ts:56

object

string | symbol

void

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

Defined in: watcher.ts:56

(this: object) => any

ClassGetterDecoratorContext

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

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

Defined in: watcher.ts:56

ClassAccessorDecoratorTarget<object, any>

ClassAccessorDecoratorContext

void | ClassAccessorDecoratorResult<object, any>

watch(value, context): any

Defined in: watcher.ts:56

undefined

ClassFieldDecoratorContext<object, any>

any

ref: PropertyDecorator<object> & ClassGetterDecorator<object, any> & ClassAccessorDecorator<object, any> & ClassFieldDecorator<object, any> = createWatchRef

Defined in: watcher.ts:65

Function

Annotation for watching values with identity comparison

It has no effect when combined with @nested.