I am not able to understand what is lazy evaluation in Bacon.js.
I wrote the example provided by Bacon using map and flatMap and I get the same result.
Here is the HTML
<input id="itemname" type="text" />
<input id="additem" type="button" value="Add Item" />
<input id="purchase" type="button" value="Purchase" />
Here is the JS for code using map
var items = $("#additem").asEventStream("click").map(function(e){
console.log("Executing");
return document.getElementById("itemname").value;
}).toProperty();
var submittedItems = items.sampledBy($("#purchase").asEventStream("click"));
Here is the JS for code using flatMap
var items = $("#additem").asEventStream("click").flatMap(function(e){
console.log("Executing");
return document.getElementById("itemname").value;
}).toProperty();
var submittedItems = items.sampledBy($("#purchase").asEventStream("click"));
For both the version of JS there is nothing logged even if I click the buttons. According to documentation the second one should output "Executing" message on the console.
Both the code works if I attach a subscriber using onValue.
Please help me understand what's wrong?