ReadonlyeventsAccess the behavior's events.
ReadonlystateAccess the behavior's state.
Static ReadonlyclusterEvery cluster behavior has an associated ClusterType defined statically.
Static ReadonlydependenciesKeep networking alive until I'm destroyed.
Static ReadonlyearlyAll ClusterBehavior initialization currently runs as part of Endpoint initialization.
StaticidThe ID of ClusterBehavior implementations is the uncapitalized cluster name.
Static ReadonlyInterfaceMethod definitions.
StaticInternalImplementation of internal state. Subclasses may override to extend.
Implementation of internal state. Subclasses may override to extend.
Static Optional ReadonlyschemaA 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.
StaticStateImplementation 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.
StaticdefaultsDefault state values.
StaticsupervisorThe 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
ProtectedcallbackCreate 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: {}ProtectedreactInstall a Reactor.
Important: The reactor MUST be a real JS function - arrow functions will not work!
StaticalterCreate a new behavior with modified cluster elements.
StaticenableCreate a new behavior with additional cluster features marked "mandatory".
This informs matter.js that an application supports these elements.
StaticforCreate 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.
StaticsetStaticsupportsDoes this behavior support functionality of a specific implementation?
StaticwithCreate a new behavior with different cluster features.
StaticwithCreate 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.