Questions tagged rxjs

Explore the latest questions and answers asked by our top developers.

Angular: How to get parameter from httpClient request and use in looping over the same request

So I have a method that get tree parents by id from the server getParentById(id:string):return httpClient I want to loop over this method and take the parentId returned from this call and put it back as a parameter to get the children, I only have the very first parentId so i pass it in the […]

By Ziad Mohamed
Categorized as angular, httpclient, rxjs Tagged , ,

Angular Guard doesnt work with rxjs filter

iam trying to use RouteGuard in my app to prevent unauthorized users from accessing it. My can activate method in Guard looks like this: canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> { return this.statusService.appStatus.pipe(filter(status=>{ return status.selectedAgency!=null; }),map(status=>{ console.log(status) if(status.selectedAgency.allowPreEdit){ return true; } else{ return false; } })) } Iam trying to filter default value […]

By Vartex05
Categorized as angular, javascript, rxjs, typescript Tagged , , ,

Angular NGRX RXJS – Subscription to other observables inside effects don’t work

I have an issue, I have a service to manage SSE and I write this service: getAllNotify(url: string): Observable<EventDTO> { return new Observable(observer => { const eventSource = this.getEventSource(url); eventSource.onopen = function () { console.log(‘connection for all data is established’); }; eventSource.onmessage = event => { => { if (eventSource.readyState !== 0) {; […]

By Andy88
Categorized as angular, ngrx, rxjs, typescript Tagged , , ,

How to write Unit test case for below function

Below code is working but code is not written as it is supposed to do. Because function is returning something but I as per my unit test function is returning value TS Code: checkSelectionFromDeletable() { return this.numbersFacade.selectedRows$.pipe( map(selectedRowCapsule => selectedRowCapsule?.selectedRows.find(x => x.owner || x.mainNumberFlag) ) ); } spec.ts it(‘should test checkSelectionFromDeletable’, () => { const […]

By anchal gaur
Categorized as angular, jasmine, rxjs, typescript, unit-testing Tagged , , , ,

Is this a reasonable way to queue Observables

I am relatively new to rxjs and angular. I have a projectRev that I need to retrieve, then I want to retrieve its parent. The API dictates two calls… I have read a lot of SO about queuing Observables but they are all trivial and I am getting lost converting the trivial example into something […]

By Greg
Categorized as angular, rxjs Tagged ,

Angular RxJS function not calling HTTP request

I have an angular store where I try to call some code, that is supposed to perform an HTTP request in an interval. This is supposed to call and HTTP endpoint and update the state of an angular store every 5 seconds. All my console.log statements are called correctly in the interval, but in the […]

By Dedi
Categorized as angular, observable, rxjs, typescript Tagged , , ,

Using flatMap in pipe

I have a service which extends another service. I’d like to override the all method to behave differently in this service. The problem I’m having is I’d like to manipulate the data I get and I only want the data value in the array I’ll return. export class ChildService extends ParentService { constructor(http: HttpClient) { […]

By nandesuka
Categorized as angular, rxjs Tagged ,

How to return data from first observable despite error inner?

I have two streams one by one: .pipe( map(() => new SemanticObject(this.objectLayer,, concatMap((semanticObject: SemanticObject) => from(semanticObject.saveObject(semanticObject.getObject())).pipe( concatMap(() => semanticObject.changeObjectStateUnom()), map((data) => data; ), ), ) I try to return data from first stream here map((data) => data;. despite if concatMap is failed. How to do that? I have tried this: .pipe( tap(() => this.loading$.next(false)), […]

By Jessy
Categorized as angular, rxjs Tagged ,

Angular store refetch data in an interval with RxJS

I have an angular store, that uses RXJS to refetch data in an interval to update the state of my component. Currently the code of my store looks like this. @Injectable() export class LeaderboardStore extends Store<LeaderboardStoreState> implements OnDestroy { private storeRequestStateUpdater: StoreRequestStateUpdater; private ngUnsubscribe$: Subject<undefined> = new Subject(); private reloadLeaderboards$: Subject<CompetitionFilteringOptions> = new Subject(); […]

By Dedi
Categorized as angular, rxjs, typescript Tagged , ,

angular how to get array of nested object from two tables one-to-many related

Hi everybody I have 2 mysql tables: itemsClass which contains a list of possible classes, and itemType which refers to itemClass and contains type values of a particular class. I’m trying to build a service which returns an Observable<Item[]>, combining two http.get Observables, suiting this interface: interface Item{ itemcClassId:any; // itemClassName:any; // itemTypeValue?:any; //if the […]

1 213

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us