How to get rid of nested subscription when searching for names?

Advertisements I wrote component that looks for github users by login. However this component has nested subscribe blocks. Please help me rewrite this component, using rxjs-operator that dont use nested subscribe blocks. Here is the live example My humble attempt to solve the problem is in the same place (see commented code). Here is a… Read More How to get rid of nested subscription when searching for names?

Property 'id' does not exist on type 'Order[]'

Advertisements Getting this strange error in my HTML that says property ‘id’ does not exist on type Order[] when it does very explicitly exists The error: Property ‘id’ does not exist on type ‘Order[]’ Here is the HTML: <div class="admin-page" *ngIf="order"> <p-card [header]="’View Order’" subheader="You can edit order status here"> <h5>Order Id</h5> <p>{{ order.id }}</p>… Read More Property 'id' does not exist on type 'Order[]'

Html string interpolation not seeing change from Angular's onPush strategy within observable

Advertisements Using Angular 14, I have in the string template interpolation in the html. I am using ChangeDetectionStrategy.OnPush. When the ngOnInit() runs and subscribe observable gets the value, I am not seeing a change in the html when this.headerName = name; is set. How can I fix this and still use onPush? <div class="col-4 gx-5">… Read More Html string interpolation not seeing change from Angular's onPush strategy within observable

is there a way to do one subscription but two callbacks (one debouced?)

Advertisements I have: thingie.valueChanges.pipe( takeUntil(this.destroy$) ).subscribe(() => doSomething()); thingie.valueChanges.pipe( takeUntil(this.destroy$), debouce(250), mergeMap((x) => forMergeMap(x)) ).subscribe((x) => doSomethingWithX(x)); Is there any way to combine that into one subscribe? >Solution : Yes, you can use the merge function of rxJs. For example: const nonDebounced$ = thingie.valueChanges.pipe( map(() => ({ type: ‘nonDebounced’ })) ); const debounced$ = thingie.valueChanges.pipe(… Read More is there a way to do one subscription but two callbacks (one debouced?)

filter rxjs operator on result valuechanges

Advertisements I am querying a firestore (7.5.0) db from angular (14.2). The where clause(s) allow only one range/inequality predicate, so I am trying to use filter to affect the second. This code let project$: Observable<Project[]> = this.firestore.collection<Project>(‘Projects’, ref => ref.where(‘EndDt’, ‘>=’, startDt)). valueChanges().pipe(filter((proj) => { // Gets whole array once so all or nothing console.log(‘proj:… Read More filter rxjs operator on result valuechanges

Why the error message returned from http interceptor is ignored?

Advertisements I have an angular project that calls api with HttpInterceptor like below. intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { return next.handle(request).pipe(catchError(error => this.errorHandler(error))); } private errorHandler(response: HttpEvent<any>): Observable<HttpEvent<any>> { console.log(response) throw response; } And the api is set up in service file like below getData(data1: string): Observable<data2: number> { return this.http.post<{data2: number;>(‘search/’, {data1} ); }… Read More Why the error message returned from http interceptor is ignored?

React useState behaviour , questions on the need of a spread (….) operator

Advertisements why cant I return expenses1 without spreading it in an array? since expenses1 which is the previous data is an array containing an object? from what i can see, {listOfExpenses} takes in an array of objects which is === expenses1 import Expenses from "./components/Expenses/Expenses"; import NewExpenses from "./components/NewExpenses/NewExpenses"; import React, { useState } from… Read More React useState behaviour , questions on the need of a spread (….) operator

how to make second stream work before first rxjs

Advertisements this.productService.createProduct(form).subscribe((res) => { this.fileUploadService.remove(imageName).subscribe((res) => { this.closeDialog(true); }) }) I have this snipped from my code and how you can see, I’m subscribing to second request inside first one, I think this is a bad solution, do you know how to make the second stream work before first one, by using rxjs operators? >Solution… Read More how to make second stream work before first rxjs