Skip to content

AbstractState ​

Entity to store the state.

You cannot create an instance of it, but State, PersistState and ComputedState inherits its behavior

Has the same api as AbstractEntity

get (method) ​

Return current state

Interface:

ts
function get(): T;

Example:

ts
const $m = new SvitoreModule();

const counter = $m.State(0);

counter.get(); // 0

getPrev (method) ​

Return prev state

Interface:

ts
function getPrev(): T;

Example:

ts
const $m = new SvitoreModule();

const counter = $m.State(0);
const counterChanged = $m.Event<number>();

counter.changeOn(counterChanged);

counterChanged.dispatch(10);

counter.getPrev(); // 0
counter.get(); // 10