1.0.7 • Published 11 months ago

red-live v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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)
1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago