-
Notifications
You must be signed in to change notification settings - Fork 85
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
Side effects and ordering in flyd.on #138
Comments
Changing this section in
to this
seems to make it work as expected for me, though I'm not sure if there are any side consequences. |
According to https://github.com/paldepind/flyd#flydonfn-s, the And if you use |
@dmitriz, he notes on the order of called functions, not the function itself. |
@StreetStrider Aren't they meant to fire simultaneously? |
@dmitriz what do you mean by «simultaneous» here? |
@StreetStrider All at the same time, as soon as their parent emits. |
@dmitriz, yes, but this is irrelevant to what TS mentions. He just notes on that |
@StreetStrider The order is not guaranteed by the spec. It may depend on the implementation and on the runtime environment. Why does it matter? |
For side effects: clearly it could have great impact |
Wow, nice picture. |
The problem is a backward compatibilty. If we forget about that - it could be usefull for simple cases. Could be planned for a major version increment. On the second thought, in complex and dynamic topologies it won't help. Order there won't be obvious from the declaration, and you should not rely on it. |
This is a quirk of the library as is. Looking at the commit history the reverse iteration is because of a rather nice performance boost. If you want some const log = a => x => (console.log(a, x), x);
const x = stream();
x.map(log('first')).map(log('second')).map(log('third'));
x('fire'); Now in stead of the dependency graph looking like this:
It looks like
Meaning things will happen in your preferred order. I'm not sure this is something we'd like to change, given it's here for perf reasons. |
This gives the result
This seems counter intuitive to me and caused some issues for me. Is there any rationale for this behavior? Could we change it? This seems like a major design decision, and if this was intended, I cannot understand the rationale.
The text was updated successfully, but these errors were encountered: