Angular 6 RXJS Import Syntax?

From rxjs 5.5, catch has been renamed to catchError function to avoid name clash. Due to having operators available independent of an Observable, operator names cannot conflict with JavaScript keyword restrictions. Therefore the names of the pipeable version of some operators have changed. import { catchError } from ‘rxjs/operators’; For throw you can use ErrorObservable. … Read more

Could not use Observable.of in RxJs 6 and Angular 6

Looks like cartant’s comment is correct, the RxJS upgrade guide doesn’t cover that method specifically but does say “Classes that operate on observables have been replaced by functions” Which seems to mean all or most of those class methods like .of, .throw etc. have been replaced by a function So instead of import { Observable, … Read more

why should we use subscribe() over map() in Angular?

If you want to return an Observable some other code can subscribe to, but you still want to manipulate the data events in the current method, use map. The actual user of the observable needs to subscribe(), because without subscribe() the observable won’t be executed at all. (forEach() or toArray() and probably others work as … Read more

flatMap, mergeMap, switchMap and concatMap in rxjs?

Taking this from a previous answer: flatMap/mergeMap – creates an Observable immediately for any source item, all previous Observables are kept alive. Note flatMap is an alias for mergeMap and flatMap will be removed in RxJS 8. concatMap – waits for the previous Observable to complete before creating the next one switchMap – for any … Read more

What is the difference between Promises and Observables?

Promise A Promise handles a single event when an async operation completes or fails. Note: There are Promise libraries out there that support cancellation, but ES6 Promise doesn’t so far. Observable An Observable is like a Stream (in many languages) and allows to pass zero or more events where the callback is called for each … Read more

tech