Open Macil opened 9 years ago
Kefir works with the above code fine.
Adding .toEventStream()
works around the issue, which initially seems fair enough if intended:
bus.plug(Bacon.constant(9).toEventStream());
I had tried that earlier, but with a log statement still in there, which caused things to not work because log would eat the event before the stream got plugged into the bus. Kefir's lack of toEventStream and insistence on properties instead of synchronously-emitting streams is making a lot of sense to me lately.
// doesn't work
bus.plug(Bacon.constant(9).toEventStream().log('foo'));
The plug
is documented as:
bus.plug(stream)
plugs the given stream to the Bus. All events from the given stream will be delivered to the subscribers of the Bus. Returns a function that can be used to unplug the same stream.
the bus.plug(property)
behaviour is undefined, and firing only x: 1
event makes sense to me.
Could plugging a property into a bus be made to throw an error if it doesn't fully work? (I guess that would be a potentially breaking change for 0.8.)
Cannot reproduce behaviour in the OP with Bacon 2.0:
var bus = new Bacon.Bus();
var unsub = bus.toProperty(1).onValue(console.log);
// -> 1
bus.plug(Bacon.constant(2));
// - > 2
Certainly according to the documentation one should just plug in EventStreams, so it's better to
...
bus.plug(Bacon.constant(3).toEventStream());
// -> 3
works as expected I guess.
This just threw me for a loop in a project:
The output given is just "x 1". I'm not sure if this is intended or not.