2.1.2 • Published 6 years ago

redux-mitt v2.1.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

redux-mitt

Latest Version CircleCI

what is this?

The redux standard API does not have an easy way to subscribe Actions and unsubscribe them.added this as a lightweight function.

install

$ npm install --save redux-mitt

setup

import { createStore, applyMiddleware } from 'redux'
import { mittMiddleware } from 'redux-mitt'

const reducer = () => {}
const store = createStore(reducer, mittMiddleware())

usage

const type = 'TEST'
const payload = { test: 'test' }
const creator = () => { return { type, payload }}
const unsubscribe = store.subscribeAction(type, action => {
  console.log(action) // { type: 'TEST', payload: { test: 'test'} }
})
// unsubscribe() # unsubscribe action
store.dispatch(creator())

API

subscribeAction(type, handler)

The first argument specifies the action type. Specific action ex:) 'SOME_ACTION' or wildcard '*' can subscribe.The second argument is callback with action.

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago