rxjs

Chain Observable

谁说我不能喝 提交于 2021-02-07 09:29:31
问题 I have a problem with observable chaining. My goal is to have this result : {Pagination, Process[]} and Process = { ....., Variables[]} I'm calling a service which return an object {Pagination, Process[]} but Variables in Process are empty. So i need to complete the process object with Variables properties. I do : this.processesService.getData().subscribe(() => { // data }); getData: Observable<any> { let processesResult = fromPromise( .... ); return processesResult.pipe( map( (result) => { <

can't seem to use 'first()' on Observable(rxjs in Angular)

空扰寡人 提交于 2021-02-07 08:49:20
问题 I read about this awesome feature in RXJS which would theoretically allow me to subscribe only for one response, but can't seem to implement it. Instead, I'm getting this error, "Property 'first' does not exist on type 'Observable'." although I am just copy-pasting from existing examples. Here's my code: implementHash( token ){ console.log('trying to implement hash', token); const req = this.http.get('http://localhost:3003/token/' + token ); const sub = req //.first() .subscribe( res =>{ sub

can't seem to use 'first()' on Observable(rxjs in Angular)

给你一囗甜甜゛ 提交于 2021-02-07 08:49:16
问题 I read about this awesome feature in RXJS which would theoretically allow me to subscribe only for one response, but can't seem to implement it. Instead, I'm getting this error, "Property 'first' does not exist on type 'Observable'." although I am just copy-pasting from existing examples. Here's my code: implementHash( token ){ console.log('trying to implement hash', token); const req = this.http.get('http://localhost:3003/token/' + token ); const sub = req //.first() .subscribe( res =>{ sub

can't seem to use 'first()' on Observable(rxjs in Angular)

前提是你 提交于 2021-02-07 08:48:08
问题 I read about this awesome feature in RXJS which would theoretically allow me to subscribe only for one response, but can't seem to implement it. Instead, I'm getting this error, "Property 'first' does not exist on type 'Observable'." although I am just copy-pasting from existing examples. Here's my code: implementHash( token ){ console.log('trying to implement hash', token); const req = this.http.get('http://localhost:3003/token/' + token ); const sub = req //.first() .subscribe( res =>{ sub

Is there any way to alter the response in an Angular 5 HttpInterceptor?

我只是一个虾纸丫 提交于 2021-02-07 08:26:19
问题 For my application I have created the following HttpInterceptor . Is there a way to return an altered version of the response to the request subscribers from here? import { Injectable } from '@angular/core'; import { HttpRequest, HttpResponse, HttpErrorResponse, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { Router } from '@angular/router'; @Injectable() export class RequestInterceptor implements HttpInterceptor {

RxJS - switchMap not emitting value if the input observable is empty array

岁酱吖の 提交于 2021-02-07 07:32:11
问题 I have the setup where I query firebase for list of user favourite posts. Basically, at first I query for user likes and then for each like get the corresponding post - all in one observable sequence. The problem arises when user dislikes the only left post. In that case (when the likes array becomes empty) nothing is fired from the observable and view is not updated (there is always at least one post present). On the one hand, this behaviour seems logical and understandable, but on the other

Angular 4 - chaining subscribe

六月ゝ 毕业季﹏ 提交于 2021-02-07 06:57:14
问题 I am calling a webservice from Angular 4 code and subscribing to the response. When the response comes, I need to parse it and using the parsed information call another webservice (and then subscribe to the response once again). How can I achieve this chaining using Rxjs subscribe. In the below code, I am calling a customer web service to get his pin code. When I get that, only then I need to call the 2nd rest service with pin code as an input. fetchCoordinates() { this.myService.get('http://

Purpose of zone.js/dist/zone-patch-rxjs

天涯浪子 提交于 2021-02-07 05:25:07
问题 Probably I am too late with the question but anyway. Could someone explain me in what cases I need to import zone's patch - zone.js/dist/zone-patch-rxjs . As far as I know the patch was added in this PR (successor of this one). I use zone and RxJs in my Angular project and despite seeing make rxjs run in correct zone in PR's description I do not fully understand when it can help me or what problems it should resolve for me. I would appreciate some code examples like before/after. Thanks in

How to unsubscribe from an Observable returned by forkJoin?

╄→гoц情女王★ 提交于 2021-02-07 05:12:33
问题 In my Angular2-typescript app, I'm using forkJoin to return an Observable only once all the parallel HTTP calls were made. Issue : the subscription callback keeps being executed indefinitely Here is my code: http.service import {Http} from "@angular/http"; constructor (private _http: HTTP) {} makeGetRequest(....) { return this._http.get(URL) .map (res => res.json) .toPromise(); my.service import {Observable} from "rxjs/Observable"; import {HttpService} from "http.service" constructor (private

How to unsubscribe from an Observable returned by forkJoin?

淺唱寂寞╮ 提交于 2021-02-07 05:07:45
问题 In my Angular2-typescript app, I'm using forkJoin to return an Observable only once all the parallel HTTP calls were made. Issue : the subscription callback keeps being executed indefinitely Here is my code: http.service import {Http} from "@angular/http"; constructor (private _http: HTTP) {} makeGetRequest(....) { return this._http.get(URL) .map (res => res.json) .toPromise(); my.service import {Observable} from "rxjs/Observable"; import {HttpService} from "http.service" constructor (private