and compositional events into functional programming. This provides an elegant way to express computation in domains such as interactive animations, robotics, computer vision, user interfaces and simulation.” - Extract from Haskell Wiki
stream for all add remove and reset events in the collection! 2 var reposProp = eventStream(repos, 'add remove reset').map(function(args) {! 3 return args[1];! 4 ! 5 // and make it a property!! 6 }).toProperty(repos);! 7 ! 8 // Results count is easy!! 9 var resultsCount = reposProp.map('.models').map('.length');
we assign the input to a backbone property! 2 var filterSearches = $('#filter').asEventStream('input')! 3 .debounce(300)! 4 .map('.target').map('.value')! 5 .assign(filter, 'set', 'filter');! 6 ! 7 // Create a model for the filter input! 8 var filter = new Backbone.Model({ filter: '' });! 9 ! 10 // We make it a Bacon Property!! 11 modelProperty(filter, 'filter')! 12 .skipDuplicates()! 13 .filter(function(text) {! 14 return text.length >= 3 || text === '';! 15 })! 16 .onValue(function(text) { repos.search(text); });