1.0.2 • Published 5 years ago

simple-bloc v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Bloc implementation for javascript

How to use

  1. Install package $ npm install blocjs
  2. 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();
    }
  }
}
  1. Use your bloc class and dispatch events to generate state changes:
const bloc = new TestBloc();
bloc.dispatch('test:event');

How to contribute