npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@blueeast/bluerain-plugin-redux

v0.6.6

Published

Adds redux state management to BlueRain OS

Downloads

35

Readme

Bluerain Redux Plugin

Greenkeeper badge

Adds Redux state management.

Usage

Run the following command in the plugin directoy:

npm i --save @blueeast/bluerain-plugin-redux

Then in your boot function, pass the plugin like this:

import BR from '@blueeast/bluerain-os';
import ReduxPlugin from '@blueeast/bluerain-plugin-redux';

BR.boot({
    plugins: [ReduxPlugin]
})

Filters

This plugin provides complete flexibility to modify the main redux store. This is done by providing various filter hooks at different stages of store initialization. All filter hooks of this plugin are executed during the execution of bluerain.system.app filter hook.

Summary

bluerain.redux.beforeInit

This hook is executed before anyother hooks are registered or executed.

bluerain.redux.app

This hook gives the ability to modify the main System App component that gets wrapped in Redux's Provider.

Parameters:

| Name | Type | Description | | --------- | --------------- | ------------------------------ | | SystemApp | React.Component | The main system app component. |

Returns:

| Name | Type | Description | | --------- | --------------- | ------------------------------ | | SystemApp | React.Component | The main system app component. |

Example:

This example wraps the System App with a Redux provider by using a withRedux higher order component (HOC).

import BR from '@blueeast/bluerain-os';
import withRedux from './withReduxBasedComponent';

BR.Filters(
    'bluerain.redux.app', 
    function AddReduxPluginToSystemApp(App) {
        return withReduxBasedComponent(App);
    }
);

bluerain.redux.initialState

This hook gives the ability to modify the initial state sent to the redux store.

Parameters:

| Name | Type | Description | | ------------ | ------ | ------------------- | | initialState | Object | initialState Object |

Returns:

| Name | Type | Description | | ------------ | ------ | ------------------- | | initialState | Object | initialState Object |

Example:

This example sets the bluerain.taskbar.active state of the redux store to true at system boot time.

import BR from '@blueeast/bluerain-os';

BR.Filters.add(
    'bluerain.redux.initialState',
    function ActivateTaskbar(state) {
        return Object.assign({}, state, {
            bluerain: {
                taskbar: {
                    active: true
                }
            }
        })
    }
);

bluerain.redux.reducers

This hook gives the ability to modify the redux store's reducer.

Parameters:

| Name | Type | Description | | -------- | ------ | ------------------------------------------------------------------------------------------------------------------- | | reducers | Object | The reducer object. This object will be sent as a param to the combineReducers of Redux after callback execution. |

Returns:

| Name | Type | Description | | -------- | ------ | ------------------------------------------------------------------------------------------------------------------- | | reducers | Object | The reducer object. This object will be sent as a param to the combineReducers of Redux after callback execution. |

Example:

This example adds a reducer to bluerain state, which will be accessible at foo.

import BR from '@blueeast/bluerain-os';
import reducer from './reducer';

BR.Filters.add(
    'bluerain.redux.reducers', 
    function AddReducer(reducers) {
        return Object.assign({}, reducers, {
            foo: 'bar'
        });
    }
);

bluerain.redux.reducers.bluerain

This hook gives the ability to modify the nested bluerain reducer.

Parameters:

| Name | Type | Description | | -------- | ------ | ------------------------------------------------------------------------------------------------------------------- | | reducers | Object | The reducer object. This object will be sent as a param to the combineReducers of Redux after callback execution. |

Returns:

| Name | Type | Description | | -------- | ------ | ------------------------------------------------------------------------------------------------------------------- | | reducers | Object | The reducer object. This object will be sent as a param to the combineReducers of Redux after callback execution. |

Example:

This example adds a taskbar reducer to bluerain state, which will be accessible at bluerain.taskbar.

import BR from '@blueeast/bluerain-os';
import reducer from './reducer';

BR.Filters(
    'bluerain.redux.reducers.bluerain',
    function AddReducers(reducers) {
        return Object.assign({}, reducers, {
            taskbar: reducer
        })
    }
);

bluerain.redux.middlewares

This hook gives the ability to add or modify custom middlewares to the main redux store.

Parameters:

| Name | Type | Description | | ----------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------- | | middlewares | Array | This is an array of redux middlewares. This array will be sent as a param to the applyMiddleware of Redux after callback execution. |

Returns:

| Name | Type | Description | | ----------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------- | | middlewares | Array | This is an array of redux middlewares. This array will be sent as a param to the applyMiddleware of Redux after callback execution. |

Example:

This example adds a taskbar reducer to bluerain state, which will be accessible at bluerain.taskbar.

import BR from '@blueeast/bluerain-os';
import customMiddleware from './customMiddleware';

BR.Filters(
    'bluerain.redux.middlewares', 
    function AddMiddleware(middlewares) {
        return middlewares.push(customMiddleware());
    }
);

bluerain.redux.enhancers

This hook gives the ability to modify the redux enhancers array. After execution, this array will be sent to the redux's compose function.

Parameters:

| Name | Type | Description | | ----------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | enhancers | Array | This is an array of redux enhancers. This array will be sent as a param to the compose of Redux after callback execution. | | middlewares | Array | This is an array of redux middlewares. This array was used to create the enhancer (by passing as a param to applyMiddleware function) that was sent inside the array as the first param of this function. |

Returns:

| Name | Type | Description | | --------- | ----- | --------------------------------------------------------------------------------------------------------------------------- | | enhancers | Array | This is an array of redux enhancers. This array will be sent as a param to the compose of Redux after callback execution. |

bluerain.redux.composed

This hook gives the ability to modify the final composed enhancers array (by passing enhancers array as a parameter to the compose function), right before they are used in the redux store. Parameters:

| Name | Type | Description | | --------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | | composed | Array | This is the composed enhancers array (by passing enhancers array as a parameter to the compose function), right before they are used in the redux store. | | enhancers | Array | This is an array of redux middlewares. This array was passed as a parameter to the compose function. The result was as the first param of this function. |

Returns:

| Name | Type | Description | | -------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | | composed | Array | This is the composed enhancers array (by passing enhancers array as a parameter to the compose function), right before they are used in the redux store. |

bluerain.redux.provider

This hook gives the ability to modify the Provider component of the redux store.

Parameters:

| Name | Type | Description | | -------- | -------- | ---------------------------------- | | Provider | Provider | The react-redux Provider component |

Returns:

| Name | Type | Description | | -------- | -------- | ---------------------------------- | | Provider | Provider | The react-redux Provider component |

Example:

This example replaces the original provider with Apollo's provider.

import BR from '@blueeast/bluerain-os';
import { ApolloProvider } from 'react-apollo';

BR.Filters(
    'bluerain.redux.provider', 
    function ChangeProvider(Provider) {
        return ({ store, children }) => (<ApolloProvider store={store} client={client}>{children}</ApolloProvider>);
});

API

ReduxPlugin

Extends Plugin

Add Redux state management to BlueRain Apps

Properties

StoreRef

This plugin saves store object in the BlueRain context. This can be accessed in the following way:

const store = ctx.refs.store;