rxjs

RxJS: How to wait for several observables, even if one or many fail

最后都变了- 提交于 2019-12-24 17:09:09
问题 I was using the zip operator to wait for three observables and process the result simultaneously: Observable .zip( this.sapService.getProductSpareParts(this.identForm.get('ident').value), this.mediacacheService.getMediaItemsByIdent(this.identForm.get('ident').value), this.mediacacheService.getMetaInfos(this.identForm.get('ident').value) ) .subscribe((results: any) => { // do stuff }); It is possible that one or many of those three observables fail and return a 500 result. In this case, all

rxjs repeat api call based on duration specified in response

…衆ロ難τιáo~ 提交于 2019-12-24 17:01:53
问题 Context I need to get data from the server that has a variable expiration (specified in the response). Once it expires I need to get it again. So I would like to create a stream that makes an asynchronous request and repeats that request after a time that is specified in the response of that request. What I tried Here is my first attempt but the repeatWhen doesn't have access to the last response. Instead of doing the repeat every 1000ms I would like to do it based on the expiration property

How to handle error when implementing Exponential backoff function?

蓝咒 提交于 2019-12-24 15:55:31
问题 I use the concept of the backoff method to retry the request if internal Server Error occurs. I mean not 401 , 403 or similar. My target is to retry the request if the server doesn't respond and/or it takes too long to send a response, for instance in case of pending status. And I do have defined timeout limit for that (in the service). My Issue is that the retryWhen function is being invoked in all the cases/errors including 401 . I believe that I might have to restructure my function/code

value from Observable within Observable using angularfire2 firestore

我是研究僧i 提交于 2019-12-24 14:40:36
问题 I am trying to query a sub-collection if exists while querying for document from collection . My first query returns/maps data properly but when I try to query the subcollection it will be stored as observable within the Observable<data> . Below is what I have/tried so far. component.ts availableCategoriesCollection: AngularFirestoreCollection<Category>; availableCategories$: Observable<CategoryId[]>; lstCategories: Observable<any>; this.availableCategoriesCollection = this.httpDataService

Problem with Observable after update app to Angular 7 and RxJS 6.3.3

廉价感情. 提交于 2019-12-24 14:13:24
问题 I updated my app to Angular 7 and RxJS 6.3.3 and I've got a problems during making changes into my code. I really need help with that, because I can't to find solution into google or stack overflow. My imports: import { Observable, of } from 'rxjs'; import { map, catchError } from 'rxjs/operators'; import { Injectable, Inject, Optional, InjectionToken } from '@angular/core'; import { Headers, ResponseContentType, Response } from '@angular/http'; import { HttpClient } from '@angular/common

rxjs zip is not lazy?

旧时模样 提交于 2019-12-24 12:22:26
问题 I 've removed the boilerplate to get to the point // a.js // My observables from stream and event this.a = Rx.Node.fromStream(this.aStream()); this.itemSource = Rx.Observable.fromEvent(ee, 'addItem'); // Zip 'em this.itemcombo = Rx.Observable.zip(this.a, this.itemSource, function (s1, s2) { return {item: s2, a: s1.toString()}; }); // Streams the lowercase alphabet rb.prototype.aStream = function aStream() { var rs = Readable(); var c = 97; rs._read = function () { rs.push(String.fromCharCode

Subscribe to a stream of events from server

有些话、适合烂在心里 提交于 2019-12-24 11:14:02
问题 I am expanding upon ping-pong example of redux-observable, and my final goal is to dispatch an action upon each received event from server . But i am having a bit of trouble wrapping my head around how to actually achieve this. What i have so far: 1.Upon opening a connection my server starts sending messages. // server.js setInterval(()=>{ ws.send(JSON.stringify({ type: 'INCREMENT', status: 200 })) console.log("sent some data") },3000) 2. On the client i have established an Observable of that

How to write an observable that unsubscribes itself rxjs6 Angular6

你说的曾经没有我的故事 提交于 2019-12-24 11:04:39
问题 I am trying to write an observable that will update database to 'away'status depending on mouseover document. And if mouse active, update back to 'online'. Here is what I have so far: private updateOnIdle(userId) { this.timer$ = fromEvent(document, 'mousemove') .pipe( first(), throttleTime(2000), switchMap(() => firebase.database() .ref(`/status/${userId}`).set({status: 'online', last_changes: firebase.database.ServerValue.TIMESTAMP}), ), map(() => timer(5000) .map(() => { firebase.database()

What is the proper way to handle concatenation of data returned from multiple http observables in angular2/4 rxjs?

↘锁芯ラ 提交于 2019-12-24 10:53:36
问题 I have 5 different URLs that each return data in the from of an array of objects. I want to concat these objects into a single array that I store local to my ANgular2 componenent. Right now, I do something like this in my ngOnInit: this.myHttpService.graburl1data() .subscribe( response => { if(!this.mylist) { this.mylist = [] this.mylist = this.mylist.concat(response); } else { this.mylist = this.mylist.concat(response); } this.myHttpService.graburl2data() .subscribe( response => { if(!this

Angular 5+ Sibling Component Communication Using RxJS (Subject)

落爺英雄遲暮 提交于 2019-12-24 10:29:40
问题 My app has listing of tiles that when clicked on will display in a dashboard. In the dashboard, when a tile is clicked, the tile details show below the dashboard (not unlike tour-of-heroes). I’m using RxJS Subject in a service to communicate successfully between Component A (available snippets), Component B (the dashboard), and the Component C (snippet details). The problem is that when I click on the one of the listings on component A, not only does it populate the dashboard like it should