states-manager

1.0.2 • Public • Published

Usage:

Import library

import State from "states-manager";

Create state machine

const status = new State();

Now we can add some onReady handlers:

status.onReady(() => {
    console.log('message1');
});

status.onReady(() => {
    console.log('message2');
});

At any time, we can forcefully change the status to 'ready' or 'wait':

loaderState.ready();        //change state to 'ready' and call all onReady handlers

Or we can create ticker for autochange ready status

status.ticker(3);           //set counter=3 and switch status to 'wait'
status.tic();               //each time the tic() method is called, the counter will decrease
status.tic();
status.tic();               //When the counter reaches zero, the status will switch to `ready` and all `onReady` handlers will be called

Readme

Keywords

Package Sidebar

Install

npm i states-manager

Weekly Downloads

2

Version

1.0.2

License

Apache-2.0

Unpacked Size

4.39 kB

Total Files

5

Last publish

Collaborators

  • dsputilov