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

await dispatch() #106

Open
ognen opened this issue Apr 3, 2018 · 1 comment
Open

await dispatch() #106

ognen opened this issue Apr 3, 2018 · 1 comment
Labels
discussion A discussion issue or PR

Comments

@ognen
Copy link
Member

ognen commented Apr 3, 2018

It may be a good idea to allow events (or any any consumer) to wait until a dispatched action has been consumed, potentially by an effect.

e.g.

effects.register(kind, action, async ({ dispatch }) => {
  await dispatch(turnOnComputer()) // waits until the action is consumed, possibly by another effect
  dispatch(login())
})

What do you think @andon, @bevkoski ?

@ognen ognen added the discussion A discussion issue or PR label Apr 3, 2018
@bevkoski
Copy link
Collaborator

I think that this is a great idea. There are a lot of examples in our Skele apps where we do workarounds because this is not yet supported. It can be useful in the following cases:

  • Wait for a read refresh to finish, then do something
  • Push a new navigation scene, then do something

However, we should be careful about handling situations where there is no one to consume the action. I am guessing that the dispatch should then result with an exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion A discussion issue or PR
Projects
None yet
Development

No branches or pull requests

2 participants