In a nutshell. You can forget about callbacks and events and work as if all data was local and stable.
The following snippet shows how easy it is to work with an Ajax Datasource, a Firebase stream and a stream of data from an HTML text input. Notice that, even though they are completely different in nature, they can all be treated like normal functions and there are no callbacks or events.
And this completely reactive of course: If data changes the text value of
#output will be updated accordingly.
// radioactive.data exposes popular datasources as reactive streams// but you can easily write your ownvar rates = radioactivedata"?";var currency = radioactivedata"#currency-selector-input";var bitcoin = radioactivedata"";radioactivereactvar value = bitcoin * ratesratescurrency;$"#output"text "1 BTC = " + currency + " " + value ;
You can completely abstract yourself from "where the data comes from" and "how often it changes" and let radioactive.react do all the heavy lifting for you.
This leads to purely functional, highly scalable and mantainable code. You can easily unit test your app or replace parts of your code with mock datasources. Here's how a more modularized version of the previous code might look like:
var rates = radioactivedata"?";var currency = radioactivedata"#currency-selector-input";var bitcoin = radioactivedata"";// notice that this function is wrapping an Ajax call and a Firebase stream// but you can completely abstact yourself from that factreturn bitcoin * ratesratescurr;radioactivereact$"#output"text "1 BTC = " + currency + " " + getCurrentBitcoinValue currency ;
You can find more examples on the /examples folder.
radioactive.data knows how to connect to a series of popular datasources out-of-the box, but the real power of Radioactive is that it is highly extensible. There are many ways to connect your own streams or async services. Third party integrations are also available.
We suggest you read The Radioactive Tutorial.
But if you are in a hurry:
$ bower install radioactive
$ npm install radioactive
Depending on where you come from, there are many ways to describe Radioactive.
- A type of data binding solution that isn’t tied to one specific UI framework.
- A minimal API which allows data producers and data consumers built by different teams to interoperate seamlessly and transparently.
- A special kind of async flow control library
- An effort to fix a long standing problem at the level where it should be solved ( at the language core ), once and for all, so we can stop reinventing the wheel and focus on the next set of problems.
Next generation UI frameworks can leverage Radioactive as their data-binding layer. Data source publishers can use Radioactive to provide a more user-friendly API.
- Bacon.js, Rx.js and similar FRP libraries
- Radioactive tightly integrates with RxJs so you can get the best of both worlds ( see radioactive.rx )
- UI Frameworks like Angular.js, Knockout, etc
- Radioactive is not a UI prescriptive UI framework. It is a fundamental low level pattern. Think of it as jQuery for reactive data
- UI Frameworks could take advantage of Radioactive as a basis of their UI templating ( aka data binding ) mechanism