1.4.1 • Published 7 years ago

redux-acb v1.4.1

Weekly downloads
15
License
MIT
Repository
github
Last release
7 years ago

!!! THIS APPROACH IS DEPRECATED: look at this react-archux-example, check store and unidirectional data flow implementation:

Application dispatcher (Service/Helper for Redux Infrastructure)

npm version

Image:

img

Interface

This module provide following interface:

createAction
boundAction
boundPromise
boundAsync

Async Example:

import { buildDispatcher } from 'redux-acb';
import store from './store';

const { boundPromise } = buildDispatcher(store);

/**
 * Bound login action creators
 *
 * @param {String} username - User name
 * @param {String} password - User password
 *
 * @returns {Function} Binder
*/
export function boundLogin(username, password) {
  return boundPromise(
    login,
    'LOGIN',
    (state) => state.Auth.loading,
    [username, password]
  );
}

/**
 * Bound logout action creators
 *
 * @returns {Function} Binder
 */
export function boundLogout() {
  return boundPromise(
    logout,
    'LOGOUT',
    (state) => state.Auth.loading
  );
}

Pure Example:

import { buildDispatcher } from 'redux-acb';
import store from './store';

const { boundAction } = buildDispatcher(store);
/**
 * Bound project information modal toggle action creator
 *
 * @returns {Function} Binder
 */
export function boundToggleProjectInformationModal() {
  return boundAction('TOGGLE_PROJECT_INFORMATION_MODAL');
}

Reducer

...

export function authReducer(state = initialState, action) {
  switch (action.type) {
    // ********************* LOGIN ******************************
    case 'LOGIN_PENDING':
        // TODO return new state
    case 'LOGIN_SUCCESS':
        // TODO return new state
    case 'LOGIN_FAIL':
        // TODO return new state
    case 'LOGOUT_PENDING':
      // TODO return new state
    case 'LOGOUT_SUCCESS':
      // TODO return new state
    case 'LOGOUT_FAIL':
      // TODO return new state
    default:
      return state;
  }
}

...
1.4.1

7 years ago

1.4.0

7 years ago

1.3.5

7 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.1.2

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago