app-saga-utils
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Installation

npm install app-saga-utils

How to use

// User.watcher.ts
import { WatcherBase } from 'app-saga-utils';

import { UserActions } from '../redux';
import { UserSaga } from './User.saga';

export class UserWatcher extends WatcherBase<UserSaga> {
  constructor() {
    super(UserSaga);

    this.watchLatest(
      UserActions.SET_USER,
      'setUser'
    );
  }
}

// or

export const userWatcher = sagaWatcher(UserSaga);
watcher.watchLatest(UserActions.SET_USER, 'setUser');
// RootSagaBase.ts
import { RootSagaBase } from 'app-saga-utils';

import { UserWatcher } from './User.watcher';

export class RootSaga extends RootSagaBase {
  constructor() {
    super();

    this.addWatchers([
      new UserWatcher(),
    ]);
  }
}

and register your saga like usually new RootSagaBase().run(sagaMiddleware);

Readme

Keywords

none

Package Sidebar

Install

npm i app-saga-utils

Weekly Downloads

3

Version

2.0.0

License

MIT

Unpacked Size

18.9 kB

Total Files

51

Last publish

Collaborators

  • tomas-light