@mixery/state-machine
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

State Machine

Yet another state-related package

State machine allows you to share value across all components through the usage of Slot. Each Slot can watch for any changes in value (either by changing its internal value or from binded slot).

Example

import * as sm from "@mixery/state-machine";

let mySlot = new sm.Slot<string>("default value (optional)");
mySlot.onChange.add((newValue, oldValue) => {
    console.log(newValue, oldValue);
});
mySlot.value = "new value";

let anotherSlot = new sm.Slot<string>();
mySlot.bindTo(anotherSlot);
anotherSlot.value; // "new value"

Readme

Keywords

Package Sidebar

Install

npm i @mixery/state-machine

Weekly Downloads

0

Version

1.0.0

License

GPL-3.0-or-later

Unpacked Size

39 kB

Total Files

10

Last publish

Collaborators

  • nahkd123