rxjs-lettable-operators

Having trouble calling RxJS share using the recommended operator import

落花浮王杯 提交于 2019-12-24 02:56:12
问题 I'm trying to understand the best practice for importing rxjs operators It seems like I should import share this way, but, the following doesn't work because it says share expects 0 arguments. I'm not quite sure how to call share correctly. import { share } from 'rxjs/operators'; ... public currentUser: Observable<User> = share(this.currentUser$.asObservable()); Doing it the old way causes no problems. However I seemed to have read that's not the preferred way to import https://www.learnrxjs

Import of lettable operators and observable creation methods

徘徊边缘 提交于 2019-12-13 15:23:11
问题 I'm upgrading to Angular 5 and RxJS 5.5.2 and trying to import Observable.of operator. Before lettable operators, we did it like this: import 'rxjs/add/observable/of'; // Usage Observable.of(...) But now importing from paths containing add is discouraged. So what is the proper way of importing and using lettable static operators now? 回答1: The operators that have now a lettable version are the instance operators. Since before 5.5.x of and any other observable creation methods can be used as in

How would I use `do` as an RxJS lettable operator?

孤者浪人 提交于 2019-11-28 13:28:05
RxJS 5.5 allows grabbing lettable operators and piping them like so: import { ajax } from 'rxjs/observable/dom/ajax' import { catchError, map, retry } from 'rxjs/operators' ajax.getJSON('https://example.com/api/test') .pipe( retry(3, 1000), map(fetchUserFulfilled), catchError(console.error) ) How would I use the do operator between these commands? The do operator was renamed in RxJS 5.5 to tap because it collided with the JavaScript do keyword. For more info see: https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#pipeable-operators 来源: https://stackoverflow.com/questions

How would I use `do` as an RxJS lettable operator?

帅比萌擦擦* 提交于 2019-11-27 07:42:07
问题 RxJS 5.5 allows grabbing lettable operators and piping them like so: import { ajax } from 'rxjs/observable/dom/ajax' import { catchError, map, retry } from 'rxjs/operators' ajax.getJSON('https://example.com/api/test') .pipe( retry(3, 1000), map(fetchUserFulfilled), catchError(console.error) ) How would I use the do operator between these commands? 回答1: The do operator was renamed in RxJS 5.5 to tap because it collided with the JavaScript do keyword. For more info see: https://github.com