Source Developer Mozilla Committer (Firefox, Servo as reviewer) ReactiveX/RxJS And some others… (whatwg html, etc) Working at VOYAGE GROUP, inc. My main work is to develop an advertising management system with using TypeScript, babel compiler, React, and RxJS.
a misnomer. ReactiveX may be functional, and it may be reactive, but “functional reactive programming” is a different animal. One main point of difference is that functional reactive programming operates on values that change continuously over time, while ReactiveX operates on discrete values that are emitted over time. http://reactivex.io/intro.html
Volta” (2008) Designed by Erik Meijer and his team Reactive Extensions in .NET (2009~) “LINQ to Events” RxJava is open sourced by Netflix (2012) By Jefer Husain https://twitter.com/jhusain https://vimeo.com/110554082
expected final value 1. Define a “source” of an event as Observable 2. Apply Operator, and create a new “check-point” Observable Scheduler can control “timing” to deliver a value
as sync const iterableToObservable = Rx.Observable.create((subscriber) => { for (const item of iterable) { // This need be blocking subscriber.next(item); } subscriber.complete(); }); // This cause blocking… iterableToObservable.subscribe((v) => console.log(v));
this._cache = cache; source.subscribe((v) => this._cache.push(v)); } next() { const done = this._cache.length > 0; let value = undefined; if (done) { value = this._cache.shift(); } return { done, value, }; } [Symbol.iterator]() { return this; } } const iter = new ObservableToIter(source); iter.next(); Limitations (Problems) On consuming first value or initializing the converter, we need to get all value from sequence. If observable returns value async, we don't transform observable to iterable, or wait to complete observable with blocking! If observable is infinite sequence, we cannot return to consumer.
values async const asyncIterableToObservable = Rx.Observable.create((subscriber) => { for await (const item of asyncIterable) { // This need not to be blocking subscriber.next(item); } subscriber.complete(); }); asyncIterableToObservable.subscribe((v) => console.log(v));
Push/Pull is duality of APIs Which is more suitable for your case? Rx is advanced observer pattern implementation that provides highly composable push APIs