1.0.2 • Published 5 years ago
simple-bloc v1.0.2
Bloc implementation for javascript
How to use
- Install package
$ npm install blocjs
- Inherit from the Bloc class:
import Bloc from 'blocjs';
class TestBloc extends Bloc {
get initialState() {
return {
state: 'initial'
};
}
async *mapEventsToState(event) {
if (event === 'test:event') {
yield new TestState();
}
}
}
- Use your bloc class and dispatch events to generate state changes:
const bloc = new TestBloc();
bloc.dispatch('test:event');