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

Chained actions - clean way? #169

Open
mkoppanen opened this issue Aug 22, 2017 · 1 comment
Open

Chained actions - clean way? #169

mkoppanen opened this issue Aug 22, 2017 · 1 comment

Comments

@mkoppanen
Copy link

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

@lexich
Copy link
Owner

lexich commented Aug 23, 2017

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

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

No branches or pull requests

2 participants