Open mbutlerw opened 6 years ago
Thanks for reporting this. I’m on vacation now, will take a look later.
I've been bitten by the same root cause of this problem just today.
For dispatch!
, the side effects are always executed before changing the state. Here's the code for latest Citrus 3.2.
For dispatch-sync!
, the execution order between the :state
effect and other side effects depends on the order of traversal of Citrus's custom doseq
macro. See the code.
Makes me think that there's a problem of predictability and/or coherence, or at least a documentation problem. If code needs to be changed, I don't know how to make it non-breaking.
I think with the the recent :citrus/handler
refactorings (#50 & #59) the behavior should be more consistent:
Specifically :state
will always be executed last:
I guess this is a breaking change in some ways and we will document this in the release notes.
Hi, I brought this up on the slack, but it got lost due to no history.
There is some surprising behaviour when mixing dispatch and dispatch sync.
The output of this is
and then if you print the reconciler once its all run
The apparent behaviour is that first the update from the
dispatch!
isn't reflected in the subsequentdispatch-sync!
method calls. However if you then check the state of the reconciler its only the result of thedispatch!
that is reflected.If you change
effect
todispatch!
as well, like soyou get the following output
So which indicates the "bug" is when you switch between
dispatch!
anddispatch-sync!
If you flip the problem and start from a
dispatch-sync!
and go todispatch!
it appears to work as expected.Output:
Wanted to raise this, even if the answer is simply a warning about mixing dispatch and dispatch-sync.