Skip to content
lautis edited this page Oct 21, 2012 · 31 revisions

Welcome to the bacon.js wiki.

Who's using Bacon.js

I know there's already quite a few users out there. I'd like to hear your stories and list some impressive cases here to gain credibility for the lib.

  • Me (Juha Paananen) - making delicious web UIs for our customers
  • Flowdock - Bacon does the heavy lifting to keep our Backbone models up-to-date in real-time
  • You?

Please add your name here if you want to confess as a bacon user!

Diagrams

I put some diagrams to illustrate how some of the more involved bacon.js methods work.

merge

Merges events from both streams a and b into the result stream.

merge

Result stream ends when both streams have ended.

combine

Combines the latest values of property a and stream or property b using a given function. In this example, a self-explanatory plus function is used.

combine

First output event is generated when both a and b have produced a value. The combined stream ends when either of the inputs ends.

sampledBy

Like combine, but only outputs a new value on a new value to the b stream.

sampledBy

Ends when b ends. If no function is given, just outputs the values of a.

flatMap

Creates a new stream for each value in the source stream, using the given function f. Merges the events from all created streams into the result stream.

flatMap

Result stream ends when both the source stream and all the so-far created streams have ended.

switch

Like flatMap, switch creates new streams for each source event. Instead of merging all created streams, it "switches" between them so that when a new stream is created, the earlierly created stream is no longer listened to.

switch

Result stream ends when source stream has ended and the latest created stream has ended.

scan

Scans stream a with given seed value. Result Property starts with the seed value and gets a new value for each new value in stream a. New values are generated using the given function, which in this case is given in the method accessor form ".concat", that will call the concat method of the strings involved.

scan

Result Property ends when source stream ends.

Clone this wiki locally