On Github omahlama / baconjs-elisa-2015
Juha Paananen @raimohanska
Olli Mahlamäki @omahlama
Distinct Events
Time-varying Value
addToCartE
cartContentsP
var addToCartE = $("#addItem") .asEventStream("click") .map(function(jqEvent) { return $("#itemName").val() }) addToCartE.onValue(bubble) runreloadrevealvar addToCartE = $("#addItem").asEventStream("click") .map(function(event) { return $("#itemName").val() }) var contentsP = Bacon.update([], addToCartE, function(items, item) { return items.concat(item) } ) contentsP.onValue(bubble)
function ShoppingCart(addItemE, removeItemE) { // ... return { contentsP } } runreload
var searchElementInitialTop = searchElement.position().top var scrollEvents = $(window) .asEventStream('scroll') .takeUntil(stateExited) scrollEvents .map(function () { return $(document).scrollTop() + 80 > searchElementInitialTop }) .skipDuplicates() .assign(searchElement, "toggleClass", "fixed")Demo
// SimCardController.js function SimCardController(...) { // ... var selectedSim = ListSelectionController( simCardElement.find("ul"), simCards, simCardDealer.getInitialSimCardIndexForOrderRow(orderRow)) .selectedOption // ... return { simCard: selectedSim.map(".id") } }
// MobileSubscriptionOrderDetailsItemView.js function MobileSubscriptionOrderDetailsItemView(...) { var outputOrderRowTemplate = { additionalInformation: { simCard: simCardController.simCard }, ... } return { orderRow: function() { return Bacon.combineTemplate(outputOrderRowTemplate) }, ... } }