0.1.4 • Published 7 years ago

saga-lite v0.1.4

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

saga-lite

A simple event bus inspired by redux-saga. Framework agnostic.

Installation

$ npm i -S saga-lite

Usage

First, create an instance of the saga in your app root:

//saga.js
import {createSaga} from 'saga-lite';

export default createSaga();

Now you may import your saga.js module, and handle/dispatch actions:

Handle an action

import saga from './saga.js';

saga.handle('MY_ACTION_TYPE', action => {
    console.log('handling', action);
});

Dispatch an action

import saga from './saga.js';

saga.dispatch({
    type: 'MY_ACTION_TYPE',
    myActionParam: 'foo'
});

Wait for an action

You may wait for an action dispatch by using "take":

import saga from './saga.js';

saga.handle('MY_ACTION_TYPE', async action => {
    const action2 = await saga.take('MY_ACTION_TYPE_2');
});
0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago