-
Notifications
You must be signed in to change notification settings - Fork 29
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
Approach to glitches #43
Comments
Hello @zyla. Thank you for asking such a great question. Hareactive is purely functional FRP library and it is primarily intended to be used in a pure setting. Glitches have the effect that some functions end up being invoked more often than they should. But, if the function is pure and doesn't have any side-effects then this is not a big problem. It's not ideal but it's not a big deal. Therefore fixing it is not a huge priority right now. That being said, we do definitely intend to fix this at some point in time. We'll probably end up doing a topological sort of the dependency graph to eliminate glitches. But, as of right now we are making large refactors of the implementation to improve performance and code clarity. |
Btw, another part of the reason why we haven't eliminated glitches yet is that we want to do it with the smallest performance overhead as possible. We've discussed implementing the topological sort such that the topological order computed while the dependency tree is being constructed and updated when new dependencies are added/removed. This will make maintaining the topological sort cheaper. But we need to get other internal features in place before we can do that. |
Sorry for the naive question - but is the test case above from this API, I don't see those functions listed? Also, feel free to correct me if I'm wrong - but I believe glitches are an indication that something is off in the semantics or the implementation is buggy. For example, here's a live demo similar to the one above via RxJS (which is not FRP proper): https://codepen.io/dakom/pen/yoqyEK (change the html to switch between v4 and v5, the glitch actually manifests in different ways which is kinda scary) More info from the book Functional Reactive Programming:
|
@dakom This test is not included in the hareactive test suite. To see the effect, paste it into (edited: messed up formatting) |
When a node (A) occurs multiple times as a dependency of another node (B), B will fire many times for each firing of A, and some of the firings will have wrong value.
The following test case illustrates the problem:
It fails with:
The presence of value
1
indicates that the framework let the application observe inconsistent values forsource
(0
and1
in this case).Is this the expected behavior? If not, are there plans to fix it?
The text was updated successfully, but these errors were encountered: