rxjs

Angular Error : multiple modules with names that only differ in casing

痴心易碎 提交于 2021-01-29 20:24:20
问题 I know this question is posted earlier also but checking each of them meticulously and checking from Github too, I found even the pattern is same but the reason of this problem is different every-time. I tried to match those scenarios and applied same solutions but nothing helped. That's why I am posting this. I am using angular version 9. The warning I am getting is, WARNING in ./node_modules/@Angular/common/__ivy_ngcc__/fesm2015/http.js There are multiple modules with names that only differ

Angular Error : multiple modules with names that only differ in casing

主宰稳场 提交于 2021-01-29 16:53:07
问题 I know this question is posted earlier also but checking each of them meticulously and checking from Github too, I found even the pattern is same but the reason of this problem is different every-time. I tried to match those scenarios and applied same solutions but nothing helped. That's why I am posting this. I am using angular version 9. The warning I am getting is, WARNING in ./node_modules/@Angular/common/__ivy_ngcc__/fesm2015/http.js There are multiple modules with names that only differ

RXJS: returning nested observables

旧城冷巷雨未停 提交于 2021-01-29 16:50:00
问题 I'm trying to return a UserDetail object which consists of a User and Results, User is retrieved via the accessToken of Account (all retrieved via individual async calls). At the moment I'm stuck at figuring out how I can return this UserDetail object when I navigate to the detailcomponent (I know it is not possible to literally return the object since the call is async, but I need to use this object in my component). The code below gives me the following error: Type 'Observable' is not

Angular/RxJS update piped subject manually (even if no data changed), “unit conversion in rxjs pipe”

ε祈祈猫儿з 提交于 2021-01-29 14:30:55
问题 I am working on an app using Angular 9 and RxJS 6.5. The functionality I have problems with uses Angular services to fetch some data from a server and provides this data to views (using RxJS behaviorSubjects). Before passing that data to the views though, I want to do some unit conversion, so that the user can use a toggle/switch to change between two units for the entire app, specifically "metric tons" and "short tons". While the actual conversion functions are provided within a dedicated

How to correctly subscribe Angular HttpClient Observable?

感情迁移 提交于 2021-01-29 13:55:37
问题 Taking example of HeroService from angular documentation. Below is a POST method in HeroService addHero (hero: Hero): Observable<Hero> { return this.http.post<Hero>(this.heroesUrl, hero, httpOptions) .pipe( catchError(this.handleError('addHero', hero)) ); } We can see that every time addHero is called a new Observable is returned. Ok now here is the service call from HeroComponent this.heroesService .addHero(newHero) .subscribe(hero => this.heroes.push(hero)); Now In my component this add

Multiple API calls with same request

我们两清 提交于 2021-01-29 13:10:43
问题 I want to make multiple HTTP calls with the same endpoint passing different id. Is there a better way to handle this from UI. We cannot change the backend right now, is there a better way? import { Component } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, forkJoin } from 'rxjs'; @Component({ selector: 'app-root', templateUrl: 'app/app.component.html' }) export class AppComponent { loadedCharacter: {}; constructor(private http: HttpClient) {}

Mapping between two arrays of observable classes

回眸只為那壹抹淺笑 提交于 2021-01-29 12:54:46
问题 I have two given classes SgFormsBase and QuestionBase with slightly different member names, and I want to translate observable[] of one to the other. import { of, Observable } from 'rxjs' import { map} from 'rxjs/operators' class SgFormsBase{ constructor( public id: number, public survey: string ){} } class QuestionBase{ constructor( public qid: number, public qsurvey: string ){} } const a = new SgFormsBase(11, 'Endo') const b = new SgFormsBase(12, 'Kolo') const sg = of([a, b] ) function

Behaviour subject value is empty when trying to fetch from a second component

烂漫一生 提交于 2021-01-29 11:01:59
问题 I am trying to share data between two components in Angular 8 using BehaviourSubject and a shared service. The code in component 1 is shown below. constructor(private appSharedService: AppSharedService) { } ngOnInit() { this.appSharedService.getCars() .subscribe(response => { this.cars = response; this.appSharedService.updateCarsList(this.cars); }, error => { console.log(error); }); } The code in the shared app-shared service is export class AppSharedService { carsSubject : BehaviorSubject

What is the proper way to return from within an angular subscription?

旧时模样 提交于 2021-01-29 10:58:28
问题 Disclaimer: This is a "good programming practices" question rather than a "fix my broken code" question. Environment Angular 5.2.9, Angular Material 5.2.4, Typescript 2.4.2, Rxjs 5.5.8 Issue I am using the mat-dialog component of the angular material library, and subscribing to the observable returned from afterClosed(). Inside of that subscription I have a simple if statement. If value is returned, return value, otherwise return null. My tslint is throwing a fit about returning from inside

Angular - Rxjs Observable - Clicking event implementation

╄→尐↘猪︶ㄣ 提交于 2021-01-29 10:30:24
问题 I'm having trouble wrapping my head around implementing an Observable clicking event to a function I already implemented. The examples I have seen so far are implemented using the fromEvent or Subject like so; import {Subject} from "rxjs/Subject"; export class Component { private clickStream$ = new Subject<Event>(); @Output() observable$ = this.clickStream.asObservable(); buttonClick(event:Event) { this.clickStream$.next(event); } } their html <button type="button" (click)="buttonClick($event