December 2015
Intermediate to advanced
144 pages
3h 37m
English
Let’s start by looking at a little reactive RxJS program. This program needs to retrieve data from different sources with the click of a button, and it has the following requirements:
It must unify data from two different locations that use different JSON structures.
The final result should not contain any duplicates.
To avoid requesting data too many times, the user should not be able to click the button more than once per second.
Using RxJS, we would write something like this:
| | var button = document.getElementById('retrieveDataBtn'); |
| | var source1 = Rx.DOM.getJSON('/resource1').pluck('name'); |
| | var source2 = Rx.DOM.getJSON('/resource2').pluck('props', 'name'); |
| | |
| | function getResults(amount) { |
| |
Read now
Unlock full access