0.3.4 • Published 6 years ago

redux-su v0.3.4

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

Redux Simple Utils

Description

Package with useful utils for Redux.

Connect decorator

Replacement for react-redux connect

Usage:

import {connect} from 'redux-su';
import actions from './redux/actions'; // { user: { auth: () => {}, login: () => {} ... }, ... [actionGroup] : { [actionName] : [actionFunc], ...} }

const selectors = {
    byPath: 'user.todos[0].title',
    byFunc: (store) => store.user.todos[0].title,
};

@connect(selectors, actions)
class Test extends React.Component {
    render () {
        return (
            <ul>
                <li>By path: {this.props.byPath}</li>
                <li>By function: {this.props.byFunc}</li>
            </ul>
        );
    }
}

Create Reducer helper

Small helper for reducer

Usage:

import {createReducer} from 'redux-su';

export default const Reducer = createReducer({
    'ACTION_1': (store, action) => ({...store, action1: 'fired!'}),
    'ACTION_2': (store, action) => ({...store, action2: action.payload}),
});
0.3.4

6 years ago

0.3.3

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.3.0-0

6 years ago

0.2.0-0

6 years ago

0.1.0

6 years ago