rxjs5

How to debug Observable values in Angular2 / Typescript?

点点圈 提交于 2019-12-21 05:17:08
问题 I have followed the tutorial for angular 2 and have a search functionality that renders a list of heroes asynchronously. <div *ngFor="let hero of heroes | async"> {{hero.name}} </div> In the component I have observable heroes: heroes: Observable<Hero[]>; Now I have implemented similar functionality in my application by I don't see anything and I don't see any errors either. I opened the debugger in Chrome and tried to check the value of heroes, but it's just some Observable wrapper of course.

How to better catch/do/empty with RXJS 5.5.2 Updates

独自空忆成欢 提交于 2019-12-21 04:59:14
问题 As staten in the ionic-angular 3.9.0 release notes (https://github.com/ionic-team/ionic/blob/master/CHANGELOG.md), using the advantages of updating to RXJS 5.5.2 could reduce the bundle size and therefore lead to a faster boot time Cool, cool, cool :) The example provided by Ionic, to migrate for example debounceTime is pretty clear, I get it. But it's pretty unclear to me how I should update my following code to take the full advantage of this RXJS update. Anyone could help me to convert it

How to use Rx.Observable.prototype.let operator?

放肆的年华 提交于 2019-12-21 03:30:26
问题 The example and explanation of the let operator (https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/let.md) is not clear. Anyone has a good example/explanation how the let operator works, and when we should use it? 回答1: &tldr; It is a convenience function for being able to compartmentalize logic and inject it into a pipeline. Longer Explanation The source is probably the most definitive explanation. It is really just passing a function which gets called with a

How to catch an error on a Request, then open a modal, then retry when modal closes with RxJS

淺唱寂寞╮ 提交于 2019-12-20 10:46:15
问题 I want to make a call to a server that can return an authorization fail (401) with Angular2's HTTP class. The flow of the request should look like that: The user makes a request to the server with myService.getSomething().subscribe() If the server returns a 401: open a modal window asking the user for his credentials. The user successfully log back into the application The modal closes and executes a callback The callback should retry the initial request (myService.getSomething().subscribe())

Is-there an opposite of the `race` operator in RxJS?

谁说我不能喝 提交于 2019-12-19 09:59:24
问题 I have two observables and I want listen to the one that emits its first value last, is there an operator for this ? Something like that : let obs1 = Rx.Observable.timer(500,500); let obs2 = Rx.Observable.timer(1000,1000); // I want the values from this one let sloth = Rx.Observable.sloth(obs1,obs2); where the sloth observable would emit the values from obs2 as it is the one who emits its first value last. If that's not the case, is there any other way ? 回答1: I like your solution (though I

Angular HTTP Interceptor how to chain an observable

孤街醉人 提交于 2019-12-19 09:47:42
问题 I am using the Azure AD adal library to do authentication. There is a call to aquire a token that returns an observable. How can this observable be added into the intercept? In the below example, how can I get the request that is set inside the subscribe to be returned as the Observable? intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { this.authAzureService.getAccessToken() .subscribe(token => { // I need this to be returned request = this

import .of() for Observable in typescript

自闭症网瘾萝莉.ら 提交于 2019-12-19 05:08:38
问题 I'm using this great repo for my angular 2 test project (TypeScript) - https://github.com/qdouble/angular-webpack2-starter. And I need to use Observable.of(..) . When I try to import it: import { Observable } from "rxjs/Observable"; import { of } from 'rxjs/observable/of'; I get: Property 'of' does not exist on type 'typeof Observable'. I also tried it the following way: import { Observable } from "rxjs/Observable"; import { of } from 'rxjs/add/observable/of'; // notice 'add' I got: node

What does subscribe do, and how it is related to Observable?

青春壹個敷衍的年華 提交于 2019-12-19 05:01:23
问题 I'm new to Angular and the tutorial I followed has the term " Observable ". The tutor explained it, but I didn't completely understand. What is an Observable , and why do we always have to call observable.subscribe() ? What does subscribe() actually do? 回答1: What is an Observable ? An Observable can be seen as a data source. That data might exist (or not) and might change over time (or not). An Observable emits data, until it has nothing to emit anymore and then completes (there are some

RxJS5 emit array items over time and repeat forever

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 04:05:50
问题 I want to emit array items over time (a one second interval between each emit) and when all items have been emitted, repeat over and over. I know how to do this, but I want to know if there is something more succinct than .. const MY_ARRAY = ['one','two','three']; const item$ = Rx.Observable.interval(1000).take(MY_ARRAY.length).repeat().map(x => MY_ARRAY[x]); item$.subscribe(x => console.log(x)); thanks output is .. "one" "two" "three" "one" "two" "three" etc EDIT: ATOW, the answers here are

RXJS control observable invocation

穿精又带淫゛_ 提交于 2019-12-18 18:59:27
问题 I use RxJs version 5 within my Angular 2 project. I want to create some observables but I don't want the observables being invoked immediately. In version 4 you could control the invocation with (for example) the Controlled command or Pausable Buffers. But that functionality is not (yet) available in version 5. How can I get the this kind of functionality in RxJs 5? My ultimate goal is to queue the created observables and invoke them one by one. The next one is only invoked when the previous