rxjs

RxJS: Observable.never() keeps like subscription

a 夏天 提交于 2019-12-31 07:43:09
问题 I'm using rxjs 5.5.6. I've created this code in order to show the behavior: Observable.of(1, 2) .do(a => { console.log(a); let d:string = null; let r = d.length; // it raises an null exception }) .catch(() => { console.log("error catched"); //exception is capture here return Observable.never(); }) .subscribe(); I was expecting that the output is: 1 error catched 2 error catched However, the output is: 1 error catched It means, the subscription terminates despite of an Observable.never() is

Angular 7: ChangeDetectorRef detectChanges() causes infinite loop when called from inside a subscription

ⅰ亾dé卋堺 提交于 2019-12-31 06:53:33
问题 I am posting here after reading all the material related to change detection and similar post and failing to solve my problem. ChangeDetectorRef detectChanges() causes infinite loop when called from inside a subscription. If I don't call detectChanges , I get ExpressionChangedAfterCheck error. I seriously don't know how to solve, and why is the ExpressionChangedAfterCheck error comes ngAfterViewInit() { this.route.params.subscribe((params) => { this.userId = params.userId; if (this.userId !=

Angular 7: ChangeDetectorRef detectChanges() causes infinite loop when called from inside a subscription

ぃ、小莉子 提交于 2019-12-31 06:53:07
问题 I am posting here after reading all the material related to change detection and similar post and failing to solve my problem. ChangeDetectorRef detectChanges() causes infinite loop when called from inside a subscription. If I don't call detectChanges , I get ExpressionChangedAfterCheck error. I seriously don't know how to solve, and why is the ExpressionChangedAfterCheck error comes ngAfterViewInit() { this.route.params.subscribe((params) => { this.userId = params.userId; if (this.userId !=

RxJs Branching If Else Logic

前提是你 提交于 2019-12-31 04:32:08
问题 onSave() { // event handler const save$ = combineLatest(this.configData.data, this.layerService.layerData) .pipe( filter(([configData]) => !_.isEmpty(configData)), take(1), tap(_ => this.loadingService.showLoading()), map(data => this.createSaveConfig(data)), flatMap(dataJSON => this.saveService.save(dataJSON)), ).share(); const saveAndReload$ = save$.pipe( filter(_ => !this.savedId), pluck('savedId'), flatMap(savedId => this.saveService.getData(savedId)), tap(reportData => this

Passing data from service to Component --> Child Components

你说的曾经没有我的故事 提交于 2019-12-31 03:00:52
问题 To be very short i am using this Plunker I have a scenario where i have to create controls dynamically by reading the elements data from a service. So when i read the data from the service its asynchronous.But i have to create some concrete objects based on the data i receive from the service and pass it to the child components. So here is my logic Html for the Main Component is as below. <ion-content padding class="container" *ngIf="questions"> <app-dynamic-form [questions]="questions"></app

Property 'subscribe' does not exist on type 'OperatorFunction<Response, Recipe[]>'

亡梦爱人 提交于 2019-12-31 02:21:30
问题 I'm trying to fetch data from firebase , but facing an error "Property 'subscribe' does not exist on type 'OperatorFunction'" any idea? whats missing here? import { Injectable } from '@angular/core'; import {HttpClient, HttpResponse} from '@angular/common/http'; import {Response} from '@angular/http'; import {RecipeService} from '../recipes/recipe.service'; import {Recipe} from '../recipes/recipe.model'; import {map} from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class

Rxjs合并数据流

非 Y 不嫁゛ 提交于 2019-12-30 22:44:57
前言 在Rxjs的世界中,为了满足复杂的需求,往往需要把不同来源 的数据汇聚在一起,把多个Observable对象的数据合并到一个 Observable对象中。 合并类操作符 concat 能够把多个Observable中的数据 内容依次合并。 import 'rxjs/add/observable/of'; import 'rxjs/add/operator/concat'; const source1$ = Observable.of(1, 2, 3); const source2$ = Observable.of(4, 5, 6); const concated$ = source1$.concat(source2$); Merge merge会第一时间订阅所有的上游Observable,然 后对上游的数据采取“先到先得”的策略,任何一个Observable只要有数据推 下来,就立刻转给下游Observable对象。 import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/timer'; import 'rxjs/add/operator/map'; import 'rxjs/add/observable/merge'; const source1$ = Observable

Observable forkJoin not firing

纵然是瞬间 提交于 2019-12-30 18:24:09
问题 I'm trying to user forkJoin on two Observables. One of them starts as a stream... If I subscribe to them directly I get a response, forkJoin isn't firing though. Any ideas? private data$: Observable<any[]>; private statuses$: Observable<any[]>; private queryStream = new Subject<string>(); .... this.data$ = this.queryStream .startWith('') .flatMap(queryInput => { this.query = queryInput return this._companyService.getCompanies(this.queryRequired + ' ' + this.query, this.page, this.sort); })

Angular 6 : where getting error module “rxjs/add/operator/map” and another error 'map' does not exist on type 'Observable<Response>'

陌路散爱 提交于 2019-12-30 17:20:30
问题 I am using Angular 6 where I am getting two errors - ERROR in ./src/app/app/img/img.service.ts Module not found: Error: Can't resolve 'rxjs/add/operator/map' in '/Users/user/Projects/A4/imageSearch/src/app/app/img' ERROR in src/app/app/img/img.service.ts(21,9): error TS2339: Property 'map' does not exist on type 'Observable'. 回答1: I faced similar problem with rxjs map operator. Currently I'm using Angular 6. To know which version you are using: ng --version or ng -v If you are also using

Angular 6 : where getting error module “rxjs/add/operator/map” and another error 'map' does not exist on type 'Observable<Response>'

拈花ヽ惹草 提交于 2019-12-30 17:19:49
问题 I am using Angular 6 where I am getting two errors - ERROR in ./src/app/app/img/img.service.ts Module not found: Error: Can't resolve 'rxjs/add/operator/map' in '/Users/user/Projects/A4/imageSearch/src/app/app/img' ERROR in src/app/app/img/img.service.ts(21,9): error TS2339: Property 'map' does not exist on type 'Observable'. 回答1: I faced similar problem with rxjs map operator. Currently I'm using Angular 6. To know which version you are using: ng --version or ng -v If you are also using