Advantage of Functional Reactive Programming over event-listeners
bacon.js, event-handling, frp, functional-programming, javascript
Solution
Is that it?
No. It's about having event streams. You still will attach listener to them in the end to execute effects, but between the source and the destination you've got a very mighty abstraction.
what's the big advantage of doing this?
The event streams do have lots of higher-order functions to easily deal with them, and for composing them without writing out all the error-prone boilerplate code.
As the docs put it quite nicely, bacon
turns your event spaghetti into clean and declarative feng shui bacon, by switching from imperative to functional. It's like replacing nested `for`-loops with functional programming concepts like `map` and `filter`. Stop working on individual events and work with event streams instead. Combine your data with `merge` and `combine` [and wield] heavier weapons [like] `flatMap` and `combineTemplate`.
Problem
I've been hearing a lot about functional reactive programming, and decided to check out what the big deal is. Going through the bacon.js documentation, it seems that the main difference is that instead of setting an event listener on a component, I create an event stream on it, and pass the event handler into the stream instead. In other words, all I really did was move the event handler from the component to the event stream. Is that it? If so, what's the big advantage of doing this?