Charanjit Singh
I like computers.
@bitspook
Disprove this statement
and prove it too
Hint: Recursion
A gentle Introduction to Reactive Programming
Approach
Tutorial
Objective
vs
wut o_O?
Synchronous
Asynchronous
Array
Observable
[1, 2, 3]
use_array()
----1------2-----3--|
use_observable()
How to use
Promise
Observable
}
subscriber
.subscribe(obj)
}
How to use
Operators
}
Array extras API
and much more
Let's write some Code
Observable.create(fn)
(observer) => {
.
.
.
}
{
onNext: fn,
onError: fn,
onCompleted: fn
}
Observable.create(fn)
(observer) => {
.
.
.
return disposable_fn;
}
{
onNext: fn,
onError: fn,
onCompleted: fn
}
When do Observable gets disposed?
When it finishes. -> onCompleted
When any error occurs. -> onError
On observable.subscribe(obj).dispose()
Observable are lazy
More than one async operations
Things get complicated when there are
Observable Factories
Bonus
Observable play very well with Promise
We can reuse our Promise in Observable chains. They're treated first class in there.
That's all
For CLCN app
The static site generator
Markdown
HTML
Markdown
+ YAML
HTML
flatMap
Synchronous DS:
b = a.map(func);
// b = [[1, 2,3], [4, 5, 6]]
b = flatten(b);
// b = [1, 2, 3, 4, 5, 6]
// map then flatten
b = flatMap(func);
// b = [1, 2, 3, 4, 5, 6];
combineLatest
zip
reduce
concat
Cold Observable
Hot Observable
Cold Observable
Hot Observable
.share()
Happy hacking : )
@bitspook
By Charanjit Singh
Reactive Functional Programming workshop @js_channel using RxJS