Skip to content

LIFETIME

bolt Methods

on.cleanup

on.cleanup(handler): Unsubscribe;

Register a cleanup handler for an object. This function is called when the object is finalized.

handler() => void

The function that should run when this object is cleaned up.

returnsUnsubscribe

A function that can be used to unregister the cleanup handler.

link(parent, child): Unsubscribe;

Link an object to its owner. When an object’s owner is [finalized], it will be [finalized].

parentobject

The object to link the child to.

childobject

The object to link to the parent.

returnsUnsubscribe

A function that can be used to unlink the child from the parent, which will prevent it from being cleaned up when the parent is cleaned up.

finalize

finalize(object): void;

Finalize an object. The object’s cleanup handlers will be called, and all linked objects will be finalized.

objectobject

The object to finalize.

Released under the MIT license