Extensions

Press shift + S to search API reference.

Model

Watchable

View source

Abstract superclass for watchable models. All watchable models expose watch and unwatch methods that allow consumers to subscribe to changes to that model.

This class should not be used directly.

Members

class Watchable
unwatch
function (keys: WatchableKey | ReadonlyArray<WatchableKey>, callback: function (model: this, key: WatchableKey, args: ...Array<any>) => unknown, context?: FlowAnyObject | null) => Array<WatchableKey>
keys

the keys to unwatch

callback

the function passed to .watch for these keys

context

the context that was passed to .watch for this callback

Unwatch keys watched with .watch.

Should be called with the same arguments given to .watch.

Returns the array of keys that were unwatched.

watch
function (keys: WatchableKey | ReadonlyArray<WatchableKey>, callback: function (model: this, key: WatchableKey, args: ...Array<any>) => unknown, context?: FlowAnyObject | null) => Array<WatchableKey>
keys

the keys to watch

callback

a function to call when those keys change

context

an optional context for this in callback.

Get notified of changes to the model.

Every call to .watch should have a matching call to .unwatch.

Returns the array of keys that were watched.