One important thing when learning functional reactive programming is how you can transform the events emitted by an observable. This way, you can use successive function calls to create new objects from the original input. This also improves the reuse of your code; every transformation of an observable creates a new observable, and each observable can have several listeners subscribed to it.
Before applying any transformations to our observables, let's implement an observable to generate and print the current date. To do this, let's use the
Bacon.interval() method. So, the following code will emit an empty object every second:
var eventSource = Bacon .interval(1000);
Bacon.interval() emits an empty object every x milliseconds, where x is the argument passed to the function–in our example, every
1000 milliseconds, which is the same as every second.
Now we can just subscribe a function to print the current date to the console. We can do this...