-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
Fix operation dispatching allowing nested operations #356
Conversation
We run the entire exchange pipeline synchronously, since that's predictable, which is how Wonka's sources work. When an exchange dispatches an operation, for instance with reexecuteOperation, this operation is hence run immediately, which can be confusing and lead to state that disagrees with itself, since the operation is essentially then "nested". Instead what we want is to queue operations up if they're dispatched nestedly, so from inside an exchange, and flush this queue after the original dispatch has completed.
I implemented this fix into the sandbox and this does not seem to execute a network request just yet. Judging through the debugExchange it does go through passed the deduplication but does not go to fetch. |
@JoviDeCroock Just tested it in your sandbox 👍 the modification seems to actually be working correctly as far as I can tell. Your sandbox was just missing the actual change in Edit: here's your sandbox with this PR's changes added to |
Yes, codesandbox didn't save my change for some reason. Not getting lucky with my statements today. Just going to approve this. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, fix can be seen working here: https://codesandbox.io/s/cool-ishizaka-9k4pf
Woah this is really interesting, thanks for the explanation @kitten. So if I'm understanding correctly, the main issue for #345 came down to the fact that, when the |
@parkerziegler Yes, that's a fair summary. Since
Yep, that's the whole solution. If we're already processing an operation (i.e. are in the exchange pipeline) then we queue up the operation and flush them synchronously after the original one completed. |
Fix #345
We run the entire exchange pipeline synchronously,
since that's predictable, which is how Wonka's
sources work.
When an exchange dispatches an operation, for
instance with reexecuteOperation, this operation
is hence run immediately, which can be confusing
and lead to state that disagrees with itself,
since the operation is essentially then "nested".
Instead what we want is to queue operations up
if they're dispatched nestedly, so from inside
an exchange, and flush this queue after the
original dispatch has completed.