-
-
Notifications
You must be signed in to change notification settings - Fork 139
Description
I have an issue where I combine two streams, then make a new object. I then branch from that stream into two others, and it's important that the values in the two streams must originate from the same object. This has to do with the other libraries I'm using, but I also think it's the expected and intended behavior. Instead, the two streams end up looking at different objects because they've received different signals.
A simple illustration of the problem is below. Note that Math.random() is a stand-in for creating a new object that the signals in streams x and y both must originate from. As an example of why this is important, consider if the object is a new data entity that comes with a randomly-generated UUID; clearly x and y must agree on what that UUID is.
Expected behavior:
- Both x and y fire every time ab fires.
- xy emits the value "true"
Actual behavior:
- ab fires, then only x fires, then ab fires, then only y fires.
- xy emits the value "false" since x and y received different signals.
const a = xs.of('a');
const b = xs.of('b');
const ab = xs
.combine(a, b)
.map(([a, b]) => Math.random())
.debug('ab');
const x = ab.map(o => o).debug('x');
const y = ab.map(o => o).debug('y');
const xy = xs
.combine(x, y)
.map(([x, y]) => x === y)
.debug('xy');
xy.addListener({
next: e => console.log(e)
});