bind
Exposes a curried api to create a middleware dispatcher with promise and thunk support.
Installation
$ npm install @koax/bind
Usage
import bind from '@koax/bind'
let dispatch = bind({fetched: 'google'})(
function * (action, next, ctx) {
if (action === 'foo') return Promise.resolve('bar')
return next()
}
])
dispatch('foo').then((res) => res) // => 'bar'
disaptch('qux').then((res) => res) // => 'qux'
API
bind (ctx) => (middleware)
-
ctx
- the context to bind the middleware to -
middleware
- array of koax middleware
Returns: dispatch function for koax middleware stack
License
MIT