@rimbu/actor
v0.15.5
Published
State management tools to create stateful logic that can be easily integrated in any framework
Maintainers
Readme
@rimbu/actor
This package offers state management tools to create stateful logic that can be easily integrated in any framework.
This package is still experimental, and therefore does not yet have complete documentation.
For complete documentation please visit the Rimbu Docs or the Rimbu API Docs.
Installation
Compabitity
Package Managers
Yarn:
yarn add @rimbu/actornpm:
npm install @rimbu/actorBun:
bun add @rimbu/actorDeno:
deno add npm:@rimbu/actorUsage
import { Actor, Obs } from '@rimbu/actor';
const obs = Obs.create({ count: 0, changes: 0 });
const actor = Actor.create(obs, {
increase() {
obs.patchState({ count: (v) => v + 1, changes: (v) => v + 1 }),
}
decrease() {
obs.patchState({ count: (v) => v - 1, changes: (v) => v + 1 }),
}
});
console.log(actor.state);
// => { count: 0, changes: 0 }
actor.increase()
actor.increase()
actor.decrease()
console.log(actor.state)
// => { count: 1, changes: 3 }Author
Created and maintained by Arvid Nicolaas.
Contributing
We welcome contributions! Please read our Contributing guide.
Contributors
Made with contributors-img.
License
This project is licensed under the MIT License. See the LICENSE for details.
