redux-api icon indicating copy to clipboard operation
redux-api copied to clipboard

Chained actions - clean way?

Open mkoppanen opened this issue 8 years ago • 1 comments

Hey,

opening new issue based on the discussions in #79.

Essentially my use-case is to chain actions "update -> fetch list", "delete -> fetch list". I use code generation heavily to create redux-api's and from that perspective postfetch has been quite useful. However, the problem with postfetch is it happens asynchronously from the first action, i.e. update finishes and during a small window the list is not yet updated (depending on client's speed etc).

Initially I started by chaining actions, but that quickly became confusing due to the "updateAndFetchList" being having to be declared under "update", rather than the "list" endpoint (correct me if I am wrong but calling "cb" in a helper executes against the endpoint the helper is defined against).

I guess what I would be after is a helper where the "update" would stay in "loading" state until all the promises / actions have resolved. Currently I am using a combination of redux-saga and postfetch, which seems to be overcomplicating the solution.

Here is one of the generated wrappers: https://gist.github.com/mkoppanen/3199794a9ce653e5a9f238ec3d6b970f

mkoppanen avatar Aug 22 '17 08:08 mkoppanen

Hi. It interesting question. At this moment I don't see another way with current implementation,but At this moment I don't have access to computer. When I'll have, we'll come back to discussion

lexich avatar Aug 23 '17 18:08 lexich