Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxJS is to events as promises are to async

In Requesting a clear, picturesque explanation of Reactive Extensions (RX)? I asked about what RX is all about, and I think, thanks to the provided answers I now got the idea.

In the referenced question i quoted a sentence from http://reactive-extensions.github.com/RxJS/ which says:

RxJS is to events as promises are to async.

Although I think that I got the idea behind RX, I do not get this sentence at all. I can not even say what it is exactly that I do not understand. It's more like ... I don't see the connection between the first and the second half of the sentence.

To me, this sentence sounds important and impressive, but I can hardly tell whether it's true or not, whether it's a great insight or not, and so on ...

Can anybody explain what the sentence means in words someone (like me) can understand who is new to all this reactive stuff?

like image 359
Golo Roden Avatar asked Feb 25 '13 08:02

Golo Roden


People also ask

Is RxJS asynchronous?

RxJS is a library for composing asynchronous and event-based programs by using observable sequences. It provides one core type, the Observable, satellite types (Observer, Schedulers, Subjects) and operators inspired by Array#extras (map, filter, reduce, every, etc) to allow handling asynchronous events as collections.

How are RxJS Observables different than Promises?

the Promise is always asynchronous, while the Observable can be either asynchronous or synchronous, the Promise can provide a single value, whereas the Observable is a stream of values (from 0 to multiple values), you can apply RxJS operators to the Observable to get a new tailored stream.

Is Observable sync or async?

An observable produces values over time. An array is created as a static set of values. In a sense, observables are asynchronous where arrays are synchronous. In the following examples, → implies asynchronous value delivery.

What is Promise in RxJS?

What is a Promise? A JavaScript Promise is an object that produces a single value, asynchronously. Data goes in, and a single value is emitted and used. Easy, straightforward way to handle incoming data.


1 Answers

Promises are a way to define computations that may happen once an asynchronous operation completes. RxJs is a way to define computations that may happen when one or more events, in a stream, occur (onNext), complete (onCompleted), or throw an exception (onError).

like image 74
Richard Anthony Freeman-Hein Avatar answered Jan 01 '23 12:01

Richard Anthony Freeman-Hein