Functional Reactive Programming is simply reactive programming using functional programming style and concepts for a side-effect freeimplementation. The functional style allows us to better understand and reason about our reactive code.
At this point, all of our application logic is essentially composed of combining, filtering and mapping the flow of event stream. Button clicks and key presses are converted into streams that are then merged into a single stream that is then mapped into another stream that is then transformed into a final stream, searchStream, that only emits events when a search is complete. One linear flow. No callback spaghetti.
This is one of the easier-to-digest summaries of FRP that I’ve read. Good job!
Pretty interesting! I’m pretty into Meteor.js which has a lot of reactive elements. Going to read up on FRP some more.
Well no, because we wouldn’t necessarily call the search function from both handlers: instead of implementing “the enter key does a search”, we can implement “the enter key does whatever the main button does” – or at least that’s one way to look at it. So instead of calling the search function in the keyup handler we could say $(“#searchButton”).click(); to call the other handler.
Obviously that still leaves us with a dependency between the two handlers (though it’s an easier to maintain dependency than calling the search function in both places), so the rewrite with bacon.js still makes sense.