observable

Angular 5 chain service observables then return observable to component

我的梦境 提交于 2019-12-24 19:30:09
问题 I have two rest calls I need to make. Rest call 2 depends on rest call 1. And I want to store each result in the service before proceeding. Then I want to return an observable to the component that calls rest call 1 so the component can subscribe in case of issues. code from service: login(username: string, password: string): Observable<AuthAccess> { // rest call 1 return this.getAuthClient() .flatMap(res => { this.client = res.body; // rest call 2 return this.authenticate(username, password)

Loop For on a BehaviorSubject stream

泪湿孤枕 提交于 2019-12-24 19:17:44
问题 My thread variable contains 3 different elements. I want to create a For loop that iterates on these three objects. threads: BehaviorSubject<{[key: string]: Thread }> = new BehaviorSubject({}); Here is my function: searchUser(): Observable<Thread> { this.searchArrayThreads = []; let element = document.getElementById('chat-window-input'); return this.threads.map((threadDictionary: {[key: string]: Thread}) => { for( let key in threadDictionary ) { console.log("key", threadDictionary[key]); if

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

Oracle JET: Knockout not updating variable

拟墨画扇 提交于 2019-12-24 10:59:25
问题 I have the following oracle jet and knockout html file <oj-dialog style="display:none;width: 600px;" id="addNewTag" title='Tag New Build' cancel-behavior='icon'> <div slot="body"> <div class="oj-form-layout"> <div class="oj-form oj-sm-odd-cols-12 oj-md-odd-cols-4 oj-md-labels-inline oj-form-cols-labels-inline oj-form-cols-max2"> <div class="oj-flex"> <div class="oj-flex-item"> <oj-label for="releaseVersion">Release Version</oj-label> </div> <div class="oj-flex-item"> <oj-input-text id=

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

Get array element in observable at particular index [Typescript]

风格不统一 提交于 2019-12-24 10:07:56
问题 I am running an ionic3 app with Angular4 and angularfire2-Firestore. How does one go about getting a single object from an Observable. I am looking to return in typescript. console.log(this.opportunity.title) // "Title1" In the code below I am using the getOpportunityByIndex() method with index as the parameter. I am getting the following output and I'm not sure what to do next. Observable {_isScalar: false, source: Observable, operator: MapOperator} operator:MapOperator {thisArg: undefined,

Angular 2 - Wait for data init from service

拈花ヽ惹草 提交于 2019-12-24 09:35:25
问题 There are 2 services: DataService - gets data from the server CacheService - subscribes to DataService and holds mapped data and component ComponentA - Injects CacheService and has foo function that handles cached data My question is - How do I ensure that my CacheService is done with data when my foo function gets called . Current solution that I kinda like but am not sure if there isn't some better Angular 2 way. Done with Rx.Observables My solution (Code is simplified): export class

Ionic & AngularFire2 best practice for unsubscribing to observables

旧巷老猫 提交于 2019-12-24 09:01:24
问题 I have a multi-page Ionic-Angular phone app that uses AngularFire2 & Firestore. One of the things I really like about Firestore is offline persistence of data. My question revolves around this data persistence and best practices for unsubscribing to AngularFire2 stream observables. My home page is a list of events and when an event is selected the app routes to a single-event page with this specific event's details. Currently I subscribe to the single-event using AngularFire2 API based on the

Property 'xxx' does not exist on type '{}'

故事扮演 提交于 2019-12-24 07:52:07
问题 I run into a strange behavior in my angular app today. ERROR in src/main(A,B): error TS2339: Property 'XXX' does not exist on type '{}'. The error occured at the following line of code xxx.subscribe(data => { this.var = data.XXX }); So basically i subscribe to an observable and map the data from the observable to an global var. My angular App works as intended, so this error seems to have no effect on the app itself, but I still can't figure out whats wrong here. Below is the console log of

Angular2 cannot use the values of a subscribe in another subscribe (observable)

徘徊边缘 提交于 2019-12-24 07:31:22
问题 I wanted to use a value from a subscribe method in another one, but it gives me undefined because it is not async. Is there a method to use those values together? I want to use this.internships another time in the following subscribe method but it becomes undefined. Thank you for helping! Code: ngOnInit(): void { this._internshipAssignmentService.getInternshipAssignments() .subscribe(internships => { this.internships = internships; <---- value which gives an object this.internshipsHelper =