Extensions

Press shift + S to search API reference.

Model

AbstractModel

View source

Abstract superclass for all models. You won't use this class directly.

Members

class AbstractModel extends Watchable<WatchableKey>
readonly idstring

The ID for this model.

readonly isDeletedboolean

true if the model has been deleted, and false otherwise.

In general, it's best to avoid keeping a reference to an object past the current event loop, since it may be deleted and trying to access any data of a deleted object (other than its ID) will throw. But if you keep a reference, you can use isDeleted to check that it's safe to access the model's data.

toString
function () => string

A string representation of the model for use in debugging.

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.