Starterclass

new Starter<T>(start: StartCallback<T>)
ParamType
startStartCallback<T>
The callback to run on start(), which may return a stop callback. required
Return
Starter<T>
Wrapper class to handle state on start/stop callback process.

Wrapper class to handle state on start/stop callback process.

  • If process has already started, starter.start() won't be called twice (including if start() didn't return a stop() callback).
  • Implements Disposable so it can be used with using, calling stop() on disposal.

Examples

const starter = new Starter(() => { console.log("start"); return () => console.log("stop"); });
starter.start();
starter.stop();

Methods

Go

Starter.start()method

Run the start callback (once).

start(...values: T): void
Go

Starter.stop()method

Run the stop callback (if one was returned by the start callback).

stop(): void