red-live
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

Red Live

Simple and lightweight middleware for binding to Redux actions.

npm version npm downloads

Installation:

npm i red-live --save

Usage:

1) Apply in Redux applyMiddleware()

import { redLiveMiddleware } from 'red-live'

createStore(
    rootReducer,
    applyMiddleware(
        redLiveMiddleware,
    )
)

2) Use before/after hook-subscribers

import { redLiveSubBefore, redLiveSubAfter } from 'red-live'

Accept two arguments:

  1. Action name(s) (String or Array of strings)
  2. Callable function on action (Function)

Example:

import { createStore, combineReducers, applyMiddleware } from 'redux'
import { redLiveMiddleware, redLiveSubBefore, redLiveSubAfter } from 'red-live'

const rootReducer = combineReducers({
    ...
})

const store = createStore(
    rootReducer,
    applyMiddleware(
        redLiveMiddleware,
    )
)

function appInitBeforeEvent(action) {
    console.log(`Event before APP_INIT apply to dispatch`)
}

function appRunAfterEvent(action) {
    console.log(`Event after APP_INIT or APP_RUN applied to dispatch`)
}

redLiveSubBefore('APP_INIT', appInitBeforeEvent)
redLiveSubAfter(['APP_INIT', 'APP_RUN'], appRunAfterEvent)

Dependents (0)

Package Sidebar

Install

npm i red-live

Weekly Downloads

0

Version

1.0.7

License

MIT

Unpacked Size

15.3 kB

Total Files

8

Last publish

Collaborators

  • codeshake