An aspiring (though currently experimental) implementation of functional-reactive programming in JavaScript, inspired by ReactiveCocoa and Rx.
Rx-style FRP essentially gives you a unified way of defining, manipulating, managing, and reacting to anything that can be reasonably represented as a stream of values. In JavaScript, these include (but are definitely not limited to) familiar idioms such as
- DOM events
- Pub/sub patterns (e.g. EventEmitter)
- Node streams
- Promises (and callbacks and everything else Promises can represent)
Like Promises, FRP provides a general abstraction for a common pattern that lets consumers write code that is declarative, composable, and reusable. Unlike Promises, FRP value streams can send multiple values at arbitrary points in time (generally when a particular interesting event occurs), and so are well suited for representing changes of a value over time, or events emitted from a source. FRP unifies these patterns under a single API and provides combinators to concisely express complex stream transformations, so that you the application author can worry less about state and keep your focus on application logic.
This project's goals are to provide a minimal FRP core, a set of useful combinators, and the means to easily adapt the core to interface with third party libraries.
It is in a very early stage, but there are already robust JS FRP libraries available for production use:
(TODO)
For basic definitions of core classes, see the terminology document.For now, you can look through the test suite to see basic usage examples, and example/example1.html to see a crude in-browser example.
- Elm is an amazing FRP language that compiles to HTML/CSS/JS
- This StrangeLoop presentation by the creator is a great intro and showcase of its expressive power
- Functional Reactive Animation is the research paper that started it all
pipeline.js is compatible with node, browser, and AMD environments. It is not yet published to npm.
See TODO.md. Contributions and questions welcome!