state-middleware-manager
v3.0.0
Published
State accumulating/reducing middleware manager
Downloads
46
Readme
state-middleware-manager
State accumulating and reducing middleware manager
Installation
npm install state-middleware-manager
Example
import { compose, Middleware } from 'state-middleware-manager'
const middleware1: Middleware<{}, { foo: string }> = (state, next) => {
expect(state).toEqual({})
return next({ foo: 'bar' })
}
const middleware2: Middleware<{ foo: string }, { mung: string }> = (state, next) => {
expect(state).toEqual({ foo: 'bar ' })
return next({ mung: 'face' })
}
compose({}, middleware1, middleware2).then((state) => {
expect(state).toEqual({
mung: 'face',
})
})