Lifetime beta
Class of @v12-engine/client
export declare class LifetimeThe owner of what a part makes (C12): each thing kept at the line it is made (own), what to undo besides (onDispose), what it hears (listen, which owns the stopping), all taken apart in the reverse order of their making by one dispose. Safe halfway through being made, and twice; every step is taken whatever the one before it did, and one that throws is said in the log. What is kept after the end is taken apart at once
Members
constructor
constructor(
what?: string, log?: Logger);Constructs a new instance of the Lifetime class
dispose
dispose(): void;Takes everything kept apart, the last kept first
disposed
get disposed(): boolean;Whether it was taken apart
listen
listen(subscribe: () => (() => void) | undefined | void): void;Hears something until the end: subscribe starts hearing and gives what stops it, which is run with the rest (lifetime.listen(() => renderer.onFrame(step)))
onDispose
onDispose(step: (() => void) | undefined | void): void;What to undo with the rest: nothing, for a part with nothing to undo
own
own<T extends Disposable>(thing: T): T;Keeps a thing, to dispose it with the rest. Gives it back, so that it is kept where it is made