Skip to content

micro-js/bind-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bind-middleware

Build status Git tag NPM version Code style

Bind middleware to a context with a dispatch and optionally a next function, so that actions can be dispatched to the middleware stack.

Installation

$ npm install @f/bind-middleware

Usage

var bindMiddleware = require('@f/bind-middleware')

var logger = require('redux-logger')
var thunk = require('redux-thunk')

var dispatch = bindMiddleware([
  thunk,
  logger()
])

dispatch(dispatch => {
  setTimeout(() => {
    dispatch({type: 'INCREMENT'})
  })
})

// log => {type: `INCREMENT`}

API

bindMiddleware(middleware, ctx, next)

  • middleware - array of redux middleware
  • ctx - context to pass to middleware
  • next - final next

Returns: A dispatch function with signature dispatch(action) that dispatches to middleware stack.

License

MIT

About

Bind redux style middleware to a context with a dispatch function.

Resources

Stars

Watchers

Forks

Packages

No packages published