Class: BedrockEventSubscriptionCache
A cache for bedrock event subscriptions. Stores off a subscription by event key, and upon teardown unregisters all subscriptions.
Constructors
new BedrockEventSubscriptionCache()
new BedrockEventSubscriptionCache(
mEvents
):BedrockEventSubscriptionCache
Parameters
Parameter | Type |
---|---|
mEvents | WorldAfterEvents |
Returns
Remarks
Constructs a new instance of the
BedrockEventSubscriptionCache
class
Methods
subscribeToBedrockEvent()
subscribeToBedrockEvent<
T
>(event
, ...params
):ReturnType
<WorldAfterEvents
[T
]["subscribe"
]>
Type parameters
Type parameter |
---|
T extends keyof WorldAfterEvents |
Parameters
Parameter | Type | Description |
---|---|---|
event | T | The event on the bedrock APIs to which to subscribe |
...params | Parameters <WorldAfterEvents [T ]["subscribe" ]> | The parameters to the subscription method for the event. Auto complete will display this for you |
Returns
ReturnType
<WorldAfterEvents
[T
]["subscribe"
]>
Remarks
Subcribes to a bedrock event using the key of the desired event. When subscribed, the event handler is both returned, but also cached internally for unsubscription. This means the caller of the subscription does not need to worry about unsubscription since the cache will automatically unsubscribe handlers on overall teardown.
teardown()
teardown():
void
Returns
void
Remarks
Cleans up the set of internal registrations and subscriptions.