0.1.10 • Published 3 years ago

state-transition-buffer v0.1.10

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

state-transition-buffer

Does state change too quickly? With stage-transition-buffer, the minimum duration of any state can be secured.

usage example

import { StateBuffer } from '../dist/src/index.js';

let connectionState = new StateBuffer({
  defaultMinDuration: 1000,
  removeLastDuplicated: true
});

let onchange = () => {
  let bufferedState = connectionState.first; //the one to show to user
  let realtimeState = connectionState.last;
  console.info(new Date(), bufferedState, realtimeState);
};
connectionState.registerChangeHandler(onchange);
connectionState.push("connecting...");
connectionState.push("connected", 2000);
connectionState.push();
connectionState.push("re-connecting...");
connectionState.push("failed to connect");
connectionState.push("re-connecting...");
connectionState.push("failed to connect");
connectionState.removeChangeHandler(onchange);
0.1.10

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago