Skip to content

Possible to await all side-effects? #3922

Discussion options

You must be logged in to vote

There's no direct way to coordinate. Dispatching a thunk can return a promise, but here you're dispatching a plain action, and then the listener kicks off the effect as a basically independent piece of logic. There's nothing that gets returned from dispatch here.

The closest option, actually, would be to start another listener that watches for the expected state change, which we've also sort of got encapsulated in a listenForCondition snippet that was listed over here:

/**
 * Attach a one-shot listener to the store, and resolves to `true` when `predicate` matches (or `false` if given `timeout` expires), then unsubscribes itself
 * @param predicate Condition to match - re…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by infinite-persistence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants