Skip to content

Latest commit

 

History

History
21 lines (13 loc) · 733 Bytes

applyToRoot.md

File metadata and controls

21 lines (13 loc) · 733 Bytes

applyToRoot(middleware)

A higher-order middleware that ensures the provided middleware is only applied to the root store.

Arguments

  1. middleware (Function): Function that conforms to the Redux middleware API or [Redux Subspaces middleware API]((/docs/advanced/middleware/CustomMiddleware.md)

Returns

(Function): A Redux Subspace middleware that applies the middleware to the root store only.

Examples

import { createStore } from 'redux'
import { applyMiddleware, applyToRoot } from 'redux-subspace'
import { reducer, middleware } from 'somewhere'

const store = createStore(reducer, applyMiddleware(applyToRoot(middleware)))