1.0.2 • Published 1 year ago

states-manager v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

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
1.0.2

1 year ago

1.0.1

1 year ago