import Actor from "actor-model";
const counter = {
init() {
return { count: 0 };
},
incrementBy(state, { number }) {
let count = state.count + number;
return { count };
},
logTotal(state) {
console.log(state.count);
}
};
const address = Actor.start(counter);
Actor.send(address, ["logTotal"]); // => { count: 0 }
Actor.send(address, ["incrementBy", { number: 2 }]);
Actor.send(address, ["logTotal"]); // => { count: 2 }