Functional Reactive Programming in Bacon.js

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

Functional Reactive Programming in Bacon.js

Lightning talk on Functional Reactive Programming in Bacon.js: a short overview of some FRP concepts with some bacon.js code samples.

Tom Kruijsen

January 14, 2016

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

29 slides
  1. var up = $('#up').asEventStream('click'); var down = $('#down').asEventStream('click'); var counter

    = // map up to 1, down to -1 up.map(1).merge(down.map(-1)) // accumulate sum .scan(0, function(x,y) { return x + y });
  2. var firstname = $("#firstname").asEventStream("keyup") .map(function(event) { return $(event.target).val(); }).toProperty(""); var

    lastname = $("#lastname").asEventStream("keyup") .map(function(event) { return $(event.target).val(); }).toProperty(""); function nonEmpty(x) { return x.length > 0 }; var valid = firstname.map(nonEmpty).and(lastname.map(nonEmpty)); valid.onValue(function(enabled) { $("#submit").attr("disabled", !enabled); });

More Decks by Tom Kruijsen

Other Decks in Programming