subspaced(mapState, [namespace])

A higher-order epic that runs the epic 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 an epic and returns a new epic that runs the original epic within the context of a subspace.

Examples

import { subspaced } from 'redux-subspace-observable'
import epic from 'somewhere'

const subspacedEpic = subspaced((state) => state.subApp)(epic)
import { subspaced } from 'redux-subspace-observable'
import epic from 'somewhere'

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

const subspacedEpic = subspaced((state) => state.subApp, 'subApp')(epic)
import { subspaced } from 'redux-subspace-observable'
import epic from 'somewhere'

const subspacedEpic = subspaced('subApp', 'subAppNamespace')(epic)
import { subspaced } from 'redux-subspace-observable'
import epic from 'somewhere'

const subspacedEpic = subspaced('subApp')(epic)

results matching ""

    No results matching ""