brocoders / redux-async-connect

It allows you to request async data, store them in redux state and connect them to your react component.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update the readme and API ?

leozdgao opened this issue · comments

It seems the example in readme.md is not working in v1.0.0-rc2, it's very confusing and I don't know how to use this in the right way. 😢

Uncaught TypeError: asyncItems.map is not a function

function wrapWithDispatch(asyncItems) {  
  return asyncItems.map(function (item) {
  ...

It seems it should be an array? But in the example:

@asyncConnect({
  lunch: (params, helpers) => Promise.resolve({id: 1, name: 'Borsch'})
})

I don't know how to do next...

commented

I've just stumbled upon this as well... It seems that with the new API the example should be rewritten like this:

@asyncConnect([{
  key: 'lunch',
  promise: (params, helpers) => Promise.resolve({id: 1, name: 'Borsch'})
}])

In short - instead of an object, you should pass an array of objects, each having 2 fields - 'key' and 'promise'.