Configurable settings for Behavior.reactTo.

interface Options {
    lock?: true | Resource | Resource[];
    offline?: boolean;
    once?: boolean;
}

Properties

Properties

lock?: true | Resource | Resource[]

Designate resources for which this reaction requires exclusive write access.

You may specify lock as a resource (e.g. a Behavior) or an array of resources. Or specify "true" to lock the reacting behavior.

If set:

  • The transaction of Behavior.context for the reacting Behavior will be exclusive during reaction

  • The transaction will own locks on the designated resources

  • The reaction will defer until the resource locks become available

offline?: boolean

Controls the context in which reaction Matter.js invokes a reactor.

  • If false (the default), the reactor runs in the same context as the emitter, or a dedicated offline context if the emitter's context is unavailable. Errors thrown by the reactor interrupt the emitter.

  • If true, the reactor runs in a dedicated, offline context. Errors thrown by the reactor are logged and won't affect the emitter

once?: boolean

Only react the next time the event emits.