tg-saga-manager
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.4 • Public • Published

tg-saga-manager

Redux-Saga helper to hot-reload sagas. Also has support for retrying failed root sagas.

Usage

import { SagaHotReloader } from 'tg-saga-manager';

import rootSaga from './sagas';

// Create store ...
const sagaHotReloader = new SagaHotReloader(store, sagaMiddleware);

// Start root saga
// Root saga should accept 1 parameter determining if it was restarted or hot-reloaded
sagaHotReloader.startRootSaga(rootSaga);

if (module.hot) {
    module.hot.accept('./sagas', () => {
        sagaHotReloader.replaceRootSaga(require('./sagas').default);
        console.log('🔁  HMR Reloaded `./sagas` ...');
    });
}

Options

  • enableHotReload: (boolean): Optionally to enable hot-reloading always or disable always. Defaults: process.env.NODE_ENV !== 'production'
  • maxRetries: (number): Optional max retries count. Default: 10
  • onError: (Function): Optional Error handler with signature (error: any) => void

Readme

Keywords

Package Sidebar

Install

npm i tg-saga-manager

Weekly Downloads

0

Version

1.0.0-beta.4

License

MIT

Unpacked Size

9.37 kB

Total Files

6

Last publish

Collaborators

  • jyrno42
  • thorgate-main
  • metsavaht