Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redux middleware configuration #11

Open
spiroid opened this issue Aug 3, 2015 · 2 comments
Open

Redux middleware configuration #11

spiroid opened this issue Aug 3, 2015 · 2 comments

Comments

@spiroid
Copy link

spiroid commented Aug 3, 2015

Hi,

I'm trying to initialize redux with this middleware, but i can't get it working for now.
I'm new to redux and started with a project based on redux 0.12

A short snippet of the application init steps:

...
import { createRedux, createDispatcher, composeStores } from 'redux';
import thunkMiddleware from 'redux/lib/middleware/thunk';
import promiseMiddleware from 'redux-promise';

import * as stores from '../stores';   

const dispatcher = createDispatcher( 
    composeStores(stores),
    [promiseMiddleware, thunkMiddleware]
);

const redux = createRedux(dispatcher);

A i missing something ?
Thx for your help.

@dariocravero
Copy link
Contributor

@spiroid I'd suggest you move to 1.0-rc already as it has important changes from 0.12 and 1.0 is just around the corner.

Adapting the release notes for redux-promise:

import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import promise from 'redux-promise';
import * as reducers from '../reducers';

const initialState = {}; // or whatever it should be
const reducer = combineReducers(reducers);
const finalCreateStore = applyMiddleware(thunk, promise)(createStore);
const store = finalCreateStore(reducer, initialState);

@spiroid
Copy link
Author

spiroid commented Aug 4, 2015

@dariocravero: many thanks this was very helpful.

I migrated to redux 1.0-rc and changed the application init code following your code snippet and the release notes.

Now it works with the async notation 👍

@acdlite: could you please update the readme with this information to help newcomers ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants