redux-eagle

2.2.0 • Public • Published

🦅 Redux Eagle

Build Status code style: prettier

Redux middleware to watch state changes.

Install

npm i --save redux-eagle

API

createEagle()

Creates the middleware function.

watch(selectors, [listener], [compare])
unwatch(selectors, [listener])

selectors
A function or an array of functions that select a slice of state.

listener
Must be a function. The listener gets called when the selected state changes.

compare
A function that compares the old and new selected state.
Default: ===

Example

basic example
import { createStore, applyMiddleware } from 'redux'
import { createEagle, watch, unwatch } from 'redux-eagle'
 
const eagle = createEagle()
const store = createStore(reducer, applyMiddleware(eagle))
 
store.dispatch(watch((state) => state.desert.mice, catchMouse))
 
function catchMouse(livingMouse, deadMouse, state) {
  console.log(livingMouse)
}
 
store.dispatch(mouseEnterDesert())

Dependents (0)

Package Sidebar

Install

npm i redux-eagle

Weekly Downloads

1

Version

2.2.0

License

MIT

Last publish

Collaborators

  • luwes