https://rxjs-dev.firebaseapp.com/api/ajax/ajax
Why rxjs ajax operator returns an Observable? I think one request gets back one response, and the connection is over. Why is it an Observable instead of a single response message?
https://rxjs-dev.firebaseapp.com/api/ajax/ajax
Why rxjs ajax operator returns an Observable? I think one request gets back one response, and the connection is over. Why is it an Observable instead of a single response message?
Any value, whether synchronously available or async, can be represented as an observable.
Rx.of()
"lifts" values into a simple observable form - you subscribe and it immediately emits the value(s) you passed to of
.
Rx.from()
converts certain values (arrays, promises, any iterable) into a logical observable equivalent.
Why are these useful? Because you can do many more things with observables vs other types of values (including promises). For instance you can cancel them if they're async.
Most importantly, it's easier to combine observables with other observables, which is what RxJS is all about.