Closed Voronchuk closed 10 years ago
That's the issue @raimohanska mentioned in https://github.com/baconjs/bacon.js/issues/297
If you call only setupBets
, but don't use returned streams for anything, then nothing happens. However log
makes subscription (i.e. "uses" streams), so data flow is forced, and something happens.
Try testing setupBets
like:
s = setupBets
s.requestResponseArray.log()
Thank you, Oleg. I was thinking in a similar way, just wished to be sure.
Mb we need a kind of .run()
function if we don't need stream data? What do you think @raimohanska?
Adding a .run()
or similar been suggested a few times already (even by myself) but we've decided against it.
If you need a forced subscription to make your application work, you've usually "done it wrong". I'm using quotes because what's right/wrong is a matter of opinion. But generally the idea of FRP (according to me, now) is to compose data using streams and properties and assign side effects to these observables to achieve desired effects. If the stream itself is supposed to do the side-effects you're "doing it wrong".
In your case though it seems that we are looking at an unfinished application where the actual subscribers would be added later. I use .log()
myself in these cases, before plugging in the actual subscriber.
Feel free to monkeypatch Observable.prototype with .run()
if you find that convenient!
Thanks for explanation.
Do anyone can explain me why code like this works:
But if I remove
$requestResponseArray.log()
nothing will happen at all.Here is logic attached to
requestJsonStream
,parseJsonStream
andprepareObjectForBaconEventTarget