0.9.1 • Published 4 years ago

@redux-tools/stream-creators v0.9.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

@redux-tools/stream-creators

The @redux-tools/epics enhancer accepts a streamCreator option, allowing you to add an additional argument to ALL epics. This package is a collection of various useful stream creators.

Usage

import { namespacedState$ } from '@redux-tools/stream-creators';
import { makeEnhancer as makeEpicsEnhancer } from '@redux-tools/epics';
import { identity, compose } from 'ramda';
import { createStore, applyMiddleware } from 'redux';
import { createEpicMiddleware } from 'redux-observable';

const epicMiddleware = createEpicMiddleware();

const store = createStore(
	identity,
	compose(
		makeEpicsEnhancer({ epicMiddleware, streamCreator: namespacedState$ }),
		applyMiddleware(epicMiddleware)
	)
);

If you want to pass multiple stream creators, you can use the applySpec function from Ramda (or any other equivalent).

const store = createStore(
	identity,
	compose(
		makeEpicsEnhancer({
			epicMiddleware,
			streamCreator: applySpec({ namespacedState$, globalAction$ }),
		}),
		applyMiddleware(epicMiddleware)
	)
);
const epic = (action$, state$, { namespacedState$, globalAction$ }) =>
	action$.pipe(ignoreElements());

API Reference

namespacedState$

A stream creator for namespaced state. Similar to state$, except it will always be the state associated with the epic. Therefore, if you have an epic injected under the foo namespace, namespacedState$ will use state.namespaces.foo.

Arguments

  1. bag (Object): Provided by the enhancer.

Returns

(Observable): An observable similar to state$ in redux-observable, except using the namespaced state.

globalAction$

A stream creator for global actions. By default, every injected epic only accepts actions matching its namespace (see @redux-tools/namespaces for more info). This stream creator allows you to react to actions from other namespaces if you need to.

Arguments

  1. bag (Object): Provided by the enhancer.

Returns

(Observable): The original unfiltered action$ passed to the epic.

0.9.1

4 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.0

5 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago