@thorgate/spa-view-manager

Redux-Saga runners used by Thorgate project template SPA variant

Usage no npm install needed!

<script type="module">
  import thorgateSpaViewManager from 'https://cdn.skypack.dev/@thorgate/spa-view-manager';
</script>

README

@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));