brocoders / redux-async-connect

It allows you to request async data, store them in redux state and connect them to your react component.
645 stars 103 forks source link

How do you get access to params and store in v1.0 decorator? #39

Closed austinmao closed 8 years ago

austinmao commented 8 years ago

Prior to v1.0 that was released today, you could do:

static reduxAsyncConnect(params, store) { ... }

https://github.com/erikras/react-redux-universal-hot-example/blob/master/src/containers/Widgets/Widgets.js shows that you can do:

@asyncConnect([{
  deferred: true,
  promise: ({store: {dispatch, getState}}) => {
    if (!isLoaded(getState())) {
      return dispatch(loadWidgets());
    }
  }
}])

I am trying to convert code I had before to v1.0 where I am using params and store. Would you add this to your docs?

kjanoudi commented 8 years ago

@austinmao see here: https://github.com/erikras/react-redux-universal-hot-example/pull/928/files#diff-eddf4c5125ed697f31c2e2d4d1038b65R10

kjanoudi commented 8 years ago

Further clarification...


@asyncConnect([{
  deferred: true,
  promise: (options) => {
    const {dispatch, getState} = options.store;
    const {params, helpers} = options;
    console.log('Params: ', params);
    if (!isLoaded(getState())) {
      return dispatch(loadWidgets());
    }
  }
}])
sars commented 8 years ago

@austinmao Yes, sorry, i haven't updates docs yet. thanks, @kjanoudi