Inconsistency with stream manipulation inside a stream
See original GitHub issueThere seems to be inconsistency between flyd.map operations inside a stream body or I’m not using it correctly. Could you verify this?
// helper function
const log = message => val => {
console.log(message, val);
return val;
};
const stream$ = flyd.stream(true);
flyd.stream(1).map(() => {
stream$
.map(log('this prints and returns true...'))
.map(log('...but it never reaches here'));
});
It works correctly if stream$
is created inline inside the flyd.map(), but if it’s created outside: it’ll only reach the first map, but not the second one.
Edit: flyd version is 0.2.6
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Common Problems with Using the reduce() Terminal ...
... with using the Java stream reduce() terminal operation, ... with Using the reduce() Terminal Operations in Java Parallel Streams.
Read more >Java Stream Generics Type Mismatch - Stack Overflow
This is because of type inference: The type is "guessed" from it's target: we know that map(anything) must return a "Stream<Class<? extends ...
Read more >Working With Maps Using Streams | Baeldung
In this tutorial, we'll discuss some examples of how to use Java Streams to work with Maps. It's worth noting that some of...
Read more >Java 8 Stream - DigitalOcean
Java Stream operations use functional interfaces, that makes it a very good fit for functional programming using lambda expression. As you can ...
Read more >Difference Between Streams and Collections in Java
A stream is not a data structure instead it takes input from the Collections, Arrays, or I/O channels. Streams don't change the original...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Props to @shpuld for fixing this issue 🎉. The atomic update code in Flyd is indeed a bit tricky. Unfortunately, I 've had a lot of my plate in the last couple of months with my bachelor’s thesis and finals. But, I’m very happy to see the conversation in this thread and that the issue was solved. Thank’s a lot everyone!
@nordfjord Thank you for providing some insight into the codebase 👍 We got one solution working like @shpuld mentioned: do you think it could work or is it even close? (It relies on a new global variable though, if that’s a problem or not…) We can do a pull request with the fix and discuss implementation as well (@paldepind ?)
Also thanks @m59peacemaker , all the help is appreciated! Wark looks interesting, and there could be some clues how to handle this problem in flyd as well. Separating atomic updates sounds like a good idea to me, at least eventually.
Flyd has been good to us and I do like the API simplicity and fantasy-land support it has among other things. I’ll try to help best I can solving this problem.