@thorgate/spa-view-manager
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.4 • Public • Published

@thorgate/spa-view-manager

Redux-Saga runners used by Thorgate project template SPA variant

Usage

import { ViewManager, ServerViewManagerWorker, takeEveryWithMatch } from '@thorgate/spa-view-manager';

function* dataLoaderSaga(match: MatchWithRoute, action) {
    console.log('React router match', match);
    
    yield put({ type: 'TEST' });
}

function* watcherAction(match, action) {
    console.log('take helper with match', match, action);
}

function* watcher() {
    yield takeEveryWithMatch('TEST', '/', watcherAction);
}

// Example route config
const routes = [
    {
        path: '/',
        exact: true,
        component: () => null,
        initial: dataLoaderSaga,
    }, {
        name: 'path-name',
        path: '/path-name',
        exact: true,
        component: () => null,
        initial: asd,
    }
];


// Client root saga
function* rootSaga() {
    yield fork(ViewManager);
}

// Server side root saga
sagaMiddleware.run(ServerViewManagerWorker, routes, createLocationAction(store.getState().router));

Readme

Keywords

none

Package Sidebar

Install

npm i @thorgate/spa-view-manager

Weekly Downloads

281

Version

1.0.0-beta.4

License

MIT

Unpacked Size

35 kB

Total Files

12

Last publish

Collaborators

  • thorgate-main
  • jyrno42
  • metsavaht