flyd: Inconsistency with stream manipulation inside a stream
There 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
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (5 by maintainers)
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.
If anyone goes to work on an atomic signaling module or an adaptation of mine, I’d love to collaborate on it.