@koax/bind

0.3.4 • Public • Published

bind

Build status Git tag NPM version Code style

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

Readme

Keywords

none

Package Sidebar

Install

npm i @koax/bind

Weekly Downloads

1

Version

0.3.4

License

MIT

Last publish

Collaborators

  • koax