wyndigo-broadcaster
v1.0.0
Published
Very simplified state broadcaster
Downloads
4
Readme
wyndigo-broadcaster
State
import { State } from '@wyndigo/broadcaster'
let stateBroadcaster = new State({
something: 'someValue'
});
// subscribe to the broadcaster
let subscriber = stateBroadcaster.subscribe(newState => {
// do something
});
// set the state
stateBroadcaster.set({ something: 'new value with object' });
stateBroadcaster.set(oldState => {
return {
something: 'new value through function'
};
});
// unsibscribe from the broadcaster
state.unsubscribe(subscriber);