3. Meridian = apps for places
Retailers, stadiums, airports,
hospitals, etc.
CARRIER 8:30 AM 100%
CARRIER 8:30 AM 100%
CARRIER 8:30 AM 100%
Transportation
CARRIER 8:30 AM 100%
Retail
Hospitals
Hotels
Campus
CARRIER 8:30 AM 100%
4.
5.
6. Agenda
Who cares about Observables!
Wait, first, what’s an Observable!
How they’ve helped me out in React!
How they might one day help you out in React
8. Why should I care about Observables (you jerk)
Why should I learn yet another async paradigm when obviously
${_.sample([Promises, Tasks, streams, generators, async/await,
CSP, Futures, Fibers, just use callbacks dammit])} are better…
9.
10. They’re coming to React (maybe)
https://github.com/facebook/react/issues/3398
11. They’re coming to Javascript (maybe)
https://www.youtube.com/watch?v=DqMFX91ToLw
12. They’re coming to Angular 2! (maybe)
http://victorsavkin.com/post/110170125256/change-detection-in-angular-2
22. Observables are like Iterables stretched out across time
[“A”, “B”, “C”, “D”, “E”] //…etc
A B C D E
23. So what’s RX
RX is a particular set of rules for Observables
onNext
Zero or more values
onError
This thing that was sending
me things is done sending
me things, forever
onComplete
25. WhoCares.gif
Remember when you found out you could replace this style
of code:
let ret = [];
let xs = [1,2,3,4,5,6];
for (let i = 0; i < xs.length; i++) {
let val = xs[i];
if (!(val % 2)) {
ret.push(val);
}
}
with:
let ret = [1,2,3,4,5,6].filter((val) => !(val % 2));
?
28. Examples
function searchWikipedia(term) {
return fetch(`http://en.wikipedia.org/w/api.php?action=opensearch&term=${term}`);
}
!
let keyup = Rx.Observable.fromEvent(document.querySelector('input'), 'keyup')
.map((e) => e.target.value)
.filter((text) => text.length > 2)
.debounce(750)
.distinctUntilChanged();
!
// don't send new requests for keyups that don't change the value, like arrow keys
!
let subscription = keyup.flatMapLatest(searchWikipedia)
.subscribe((data) => {
// bind data to DOM
});
!
// when we're finished
!
subscription.dispose();
29. How can we use these with React
Short answer: I don’t really know yet
• Pass streams around as props!
• Use them to manage real time event streams
(websockets etc)!
• Use them to model data flows in Flux!
• Use them to model state changes in components!
• Animations?
30. !
Historically, our apps have derived a user’s current location
through piece of network infrastructure called a Real Time
Location System (RTLS)
APs work in coordination with the RTLS to
calculate position based on RSSI
triangulation.
The Problem
32. The Solution
We can solve this with a simple transformation between the
two maps…
But to create this transformation we need at least two
reference points in both coordinate systems.
41. Things I haven’t tried yet
Combining Observables with Flux
• https://github.com/fdecampredon/rx-flux!
• http://r3dm.github.io/thundercats/!
• https://github.com/cell303/flurx
42. Things I didn’t have time for
• Backpressure in Observables
https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/backpressure.md
• Hot vs Cold Observables
https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/creating.md#cold-vs-hot-observables
• Schedulers
https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/schedulers.md
43. Sources
• Intro To Reactive Programming you’ve been missing
(https://gist.github.com/staltz/868e7e9bc2a7b8c1f754)!
• Coursera’s Reactive Programming Course (starts this
week!)!
• reactivex.io!
• @ReactiveX