-
Notifications
You must be signed in to change notification settings - Fork 76
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
race condition for fast effects #15
Comments
You should not be incrementing the count in your effect. Instead, the Receive action should include the amount to increment not the new count, because that count might be stale. |
I think what you're saying is change it to trace "EffIncrement" \_ -> { state: count, effects: [pure $ Increment]} But that doesn't solve the problem. I think the state updates are happening in the right order, it's the renderings that get out of sequence? i.e., I think (modulo me not understanding purescript-signal that well) what's happening is something like
Does that make sense? |
Ah, I see the issue. This looks like a bug. I'm working on it. |
This is fixed in |
I want an
Action
to do nothing to theState
and kick off an effect (whose result does something to the state). The problem is that inupdate
I don't see a way not to set the state, even if I want it not to change. And if the effect returns very quickly, its signal gets rendered before the do-nothing change to the state. Here is a really contrived minimal example (the actual way I found this was more complicated and involved random numbers):If I click on
EffIncrement
, theReceive (count + 1)
signal gets rendered first. So if I clickEffIncrement
, what happens is theReceive 1
redraw happens before thestate: 0
redraw, so the state gets updated but the UI appears not to. Then if you (e.g.) clickIncrement
it goes up to 3.A hacky solution is to artificially add a small delay to my fast effects, is there a better way?
(gist with full code: https://gist.github.com/joelgrus/f65b4106cdf32f4bc1109f0e1a0e0497)
The text was updated successfully, but these errors were encountered: