rxjs

Angular 2 Observable.retryWhen doesn't include status in error

你。 提交于 2019-12-11 05:38:29
问题 I am trying to get my code updated so that I am able to use refresh tokens to keep a user logged in. I intend to do this using the Observable.retryWhen method. However I am running into an issue where the error being passed to my retry method has a type of Subject instead of Response like I expected and have gotten in the past. This is an issue because I need to check if the status is a 401 and Subject doesn't include the status of the response. Also the catch works as expected passing a

Is there an equivalent to RxJs<=4#ofArrayChanges in RxJs5

耗尽温柔 提交于 2019-12-11 05:28:10
问题 I am using Angular2 and I want to track changes in array,but there is only RxJs5,and seems it hasn`t such functionality. 回答1: There is no equivalent. The Object.observe proposal has been withdrawn from ES7, so there is little point in having ofArrayChanges or ofObjectChanges in RxJS 5. 来源: https://stackoverflow.com/questions/39181404/is-there-an-equivalent-to-rxjs-4ofarraychanges-in-rxjs5

RxJS how to return Observable with default error handling function

浪子不回头ぞ 提交于 2019-12-11 05:26:43
问题 In my application I have some methods returning an Observable: public myMethodReturningObs(...): Observable { return this.http.get(...); // this will return an Observable } then I call this method in several places around my application: this.service.myMethodReturningObs().subscribe( (data) => { /* do something with data */ }, (error) => { console.log('Error!'); } ); // ... this.service.myMethodReturningObs().subscribe( (data) => { /* do something else with data */ }, (error) => { console.log

Angular 2 - Using RXJS Observables

喜你入骨 提交于 2019-12-11 05:26:09
问题 I have the following jsfiddle in Angular 1 which has two components, boxA, boxB that listens to a RXJS subject called msgSubject defined in msgService. The mainCtrl broadcast a message through msgService broadcast function. If boxA and boxB are subscribed to the msgSubject (there is an option to unsubscribe) the updated message will show in each respective component view. Angular 1 Observable Js Fddile My question is how do I replicate this in Angular 2? I've googled and most of the tutorials

rxjs - combining inner observables after filtering

跟風遠走 提交于 2019-12-11 05:23:40
问题 I call backend that respond with: [ "https://some-url.com/someData1.json", "https://some-url.com/someData2.json" ] Each JSON can have following schema: { "isValid": boolean, "data": string } I want to get array with all data, that have isValid is set to true backend.get(url) .pipe( mergeMap((urls: []) => urls.map((url: string) => backend.get(url) .pipe( filter(response => response.isValid), map(response => response.data) ) ) ), combineAll() ) When both .json have "isValid" set to true, I get

What does a state mean in Angular application?

大城市里の小女人 提交于 2019-12-11 05:14:40
问题 I am new to NgRx and going through its documentation. But, at the beginning, I'm encountered with the following sentence: State is a single, immutable data structure. What does the state mean in simple words? Need some simple examples to understand this concept. Do I need to learn Flux and Redux to understand these concepts? 回答1: Simply put, a state in ngrx (or redux, or other state managment systems) is how your system is described in a single point in time. You can think about it as a plain

Angular2: subscribe to BehaviorSubject not working

孤街浪徒 提交于 2019-12-11 05:08:41
问题 I have an Alert.Service.ts which saves alerts fetched from another service in an array. In another header.component.ts , I want to get the real-time size of that array. So, in Alert.Service.ts I have @Injectable() export class AlertService { public static alerts: any = []; // Observable alertItem source private alertItemSource = new BehaviorSubject<number>(0); // Observable alertItem stream public alertItem$ = this.alertItemSource.asObservable(); constructor(private monitorService:

waiting observable subscribe inside foreach to end

守給你的承諾、 提交于 2019-12-11 05:04:49
问题 Im iterating over an array of objects and for each iteration i run a observable.subscribe, how can i ensure that the all the subscribes were completed, so i can call another function? this is the function calculaSimulacoesPorInscricao(){ let lista = ["2019-01-01","2020-02-02","2021-01-01","2022-01-01","2023-01-01"]; this.cliente.coberturas.forEach(cobertura => { cobertura.MovimentosProjetados = []; this._dataService.ObterSimulacao(cobertura.codigoInscricao,lista) .subscribe((data:any[])=>{

Angular RxJs level up during looping an array

不羁的心 提交于 2019-12-11 04:56:02
问题 I have an http get request to get an array like [ {name: 'name1', id: 1, specialProp: [] }, {name: 'name2', id: 2, specialProp: [] } ] I need to get each of array items, take an id and send a request to server to get some information. The results should be written into the property specialProp . After that I need to take the array of the prop specialProp and for each item get some data, put it into anotherSpecialProp . In the end I should have the final array like [ {name: 'name1', id: 1,

RxJS: takeUntil with multiple actions and different filters?

烈酒焚心 提交于 2019-12-11 04:46:34
问题 I have an Observable that I want to continue executing until: 1) the uploadActions.MARK_UPLOAD_AS_COMPLETE action is called with a certain payload OR 2) the uploadActions.UPLOAD_FAILURE action is called with any payload This is as far as I could get (and doesn't work): return Observable.interval(5000) .takeUntil( action$ .ofType( uploadActions.UPLOAD_FAILURE, uploadActions.MARK_UPLOAD_AS_COMPLETE ) .filter(a => { // <---- this filter only applies to uploadActions.MARK_UPLOAD_AS_COMPLETE const