subspaced(mapState, [namespace])

A higher-order saga that runs the saga in a subspace.

Arguments

  1. mapState (Function|string): A selector to derive the state of the subspace. The selector is provided the parent state as the first parameter and the root state as the second parameter. If passed as a string, a selector is created for that key on the provided state.
  2. namespace (string): An optional namespace to scope actions with.

If mapState is passed as a string and no namespace is provided, the provided string is used for both. To prevent this, pass null as the second parameter.

Returns

(Function): A function that accepts a saga (generator function) and returns a new saga that runs the original saga within the context of a subspace.

Examples

import { subspaced } from 'redux-subspace-saga'
import saga from 'somewhere'

const subspacedSaga = subspaced((state) => state.subApp)(saga)
import { subspaced } from 'redux-subspace-saga'
import saga from 'somewhere'

const subspacedSaga = subspaced((state, rootState) => ({ ...state.subApp, root: rootState }))(saga)
import { subspaced } from 'redux-subspace-saga'
import saga from 'somewhere'

const subspacedSaga = subspaced((state) => state.subApp, 'subApp')(saga)
import { subspaced } from 'redux-subspace-saga'
import saga from 'somewhere'

const subspacedSaga = subspaced('subApp', 'subAppNamespace')(saga)
import { subspaced } from 'redux-subspace-saga'
import saga from 'somewhere'

const subspacedSaga = subspaced('subApp')(saga)

results matching ""

    No results matching ""