simple-bloc
1.0.2 • Public • Published
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');
How to contribute
Package Sidebar
Install
Weekly Downloads