Multiple files

We recommend to expose function that will generate reducer on demand.

Why ? Because, if you want to override defaults, you have to override BEFORE creating instance of Rule.

1 - reducer1

import { Rule, Generator } from 'redux-autoreducers';

function getReducer() {
    const rule = new Rule('GET_ALL');
    const generator = new Generator([rule]);
    return generator.generate();
}

export default getReducer;

2 - reducer2

import { Rule, Generator } from 'redux-autoreducers';

function getReducer() {
    const rule = new Rule('TEST');
    const generator = new Generator([rule]);
    return generator.generate();
}

export default getReducer;

3 - combine

import { combineReducers } from 'redux';
import reducer1 from './reducer1';
import reducer2 from './reducer2';

function getReducer() {
    return combineReducers({
      reducer1: reducer1(),
      reducer2: reducer2(),
    });
}

export default getReducer;

4 - store

import { createStore } from 'redux';
import combine from './combine';

// Override defaults here
// ...

export default createStore(combine());

results matching ""

    No results matching ""