simple-bloc

1.0.2 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i simple-bloc

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

51.4 kB

Total Files

18

Last publish

Collaborators

  • calveto