addWillTickListener
The addWillTickListener
method registers a listener function with the Manager
that will be called just before the Manager
ticks.
addWillTickListener(listener: TickListener): string
Type | Description | |
---|---|---|
listener | TickListener | The function that will be called just before the |
returns | string | A unique |
The provided listener is a TickListener
function, and will be called with a reference to the Manager
.
Example
This example registers a listener that is called just before each Manager
tick.
import {createManager} from 'tinytick';
const manager = createManager();
const listenerId = manager.addWillTickListener(() =>
console.log('Manager will tick'),
);
manager.start();
// ... wait 250ms, long enough for two ticks to occur
// -> 'Manager will tick'
// -> 'Manager will tick'
manager.stop();
manager.delListener(listenerId);
Since
v1.2.0