Readonly
eventsAccess the behavior's events.
Readonly
stateAccess the behavior's state.
Static
Readonly
clusterEvery cluster behavior has an associated ClusterType defined statically.
Static
Readonly
dependenciesKeep networking alive until I'm destroyed.
Static
Readonly
earlyAll ClusterBehavior initialization currently runs as part of Endpoint initialization.
Static
idThe ID of ClusterBehavior implementations is the uncapitalized cluster name.
Static
Readonly
InterfaceMethod definitions.
Static
InternalImplementation of internal state. Subclasses may override to extend.
Implementation of internal state. Subclasses may override to extend.
Static
Optional
Readonly
schemaA behavior's schema controls access to data, commands and events.
Schema is inferred from the methods and properties of the behavior but you can specify explicitly for additional control.
Static
StateImplementation of endpoint-scoped state. Subclasses may override to extend.
Implementation of endpoint-scoped state. Subclasses may override to extend.
The context in which the behavior operates.
The endpoint's environment.
Supported features as a flag object.
The session in which the behavior has been invoked.
Static
defaultsDefault state values.
Static
supervisorThe data supervisor for the behavior. The supervisor controls validation and access to behavior data.
Release resources. This is the public API for releasing application resources held by behaviors in internal state.
Execute logic with elevated privileges.
The provided function executes with privileges escalated to offline mode. This is not commonly necessary.
Elevated logic effectively ignores ACLs so should be used with care.
Note that interactions with the behavior will remain elevated until the synchronous completion of this call. You should only elevate privileges for synchronous logic.
the elevated logic
Protected
callbackCreate a generic callback function that has the same properties as a Reactor.
Like a reactor, the callback's "this" will be bound to an active Behavior instance. Because of this: The reactor MUST be a real JS function - arrow functions will not work!
Behaviors are ephemeral and should not perform initialization in their constructor. They can override this method instead.
This method may be synchronous or asyncronous. If asynchronous, the behavior will not be available for external use until initialization completes.
Optional
_options: {}Protected
reactInstall a Reactor.
Important: The reactor MUST be a real JS function - arrow functions will not work!
Static
alterCreate a new behavior with modified cluster elements.
Static
enableCreate a new behavior with additional cluster features marked "mandatory".
This informs matter.js that an application supports these elements.
Static
forCreate a new behavior for a specific ClusterType.
If you invoke directly on ClusterBehavior you will receive a new implementation that reports all commands as unimplemented.
If you invoke on an existing subclass, you will receive a new implementation with the cluster in the subclass replaced. You should generally only do this with a ClusterType with the same ID.
Static
setStatic
supportsDoes this behavior support functionality of a specific implementation?
Static
withCreate a new behavior with different cluster features.
Static
withCreate a ClusterBehavior like this one with different interface methods.
The Interface "property" is type-only. We define a method however to keep the API consistent. At runtime the method is a no-op.
A Behavior with specialization for a specific cluster.
To implement cluster functionality you should use a subclass provided by ClusterBehavior.for with the ClusterType you are implementing. Most commonly you would use one of the predefined implementations matter.js includes.
Subclasses can be modified using the static builder methods or extended like a normal class.
Behaviors should store all mutable state in their Behavior.state property. Other fields will be transient and may not be retained across invocations.
ClusterBehaviors may be instantiated with unsupported mandatory commands and attributes. This is currently results in a runtime error but it will not cause a type error during development.