Multiple requests with different headers with Rxjs

I have this request that while hasProcessado == true performs 10 more requests and issues the last, if it fails 3 more requests are made. But when I make the last request I need to notify the backend with a different header My request: public getProfitability(): Observable<Profitability> { let result = this.http.get<Profitability>(this.configService.generateNewUrl(`${environment.api.newEndpoints.profitability}`), {headers: this.configService.concatenateHeaders()}) return […]

By Guilherme Lucas
Published
Categorized as angular, javascript, rxjs, typescript Tagged , , ,

Capture last value of an observable with multiple requests

I have a service layer responsible for handling the data and sending it to components that use the same value. I need to make requests to the api, as long as the value is isProcessed == false it will do 10 attempts every half a second. If it fails during the attempts, it will only […]

By Guilherme Lucas
Published
Categorized as angular, javascript, rxjs, typescript Tagged , , ,

forkJoin undefined when share component (and combining boolean variables)

I have a service used in many components and I need to share the result of a forkjoin, but the component is coming as undefined My service logic layer @Injectable({ providedIn: ‘root’ }) export class CoreStateService { private subject = new BehaviorSubject<any>([]); hasError$: Observable<any> = this.subject.asObservable(); constructor(private api: HomeGuardService) {} public verifyFailed(): Observable<any>{ return forkJoin([this.api.getPerfilNew$, […]

By Guilherme Lucas
Published
Categorized as angular, javascript, rxjs, typescript Tagged , , ,

Dont return value with observable, from the service layer to the component

I’m trying to pass the return of a service layer with subject to the components. My service that connects with api: public getPerfilNew$(): Observable<PerfilInvestidor> { return this.http.get<PerfilInvestidor>(`${environment.api.basePosicaoConsolidada}/consolidado`) .pipe( map(res => res), shareReplay(1), catchError(err => { console.log(‘Error in perfil’, err); return throwError(err); }) ) } Layer responsible for logic, I use it when several components depend […]

By Guilherme Lucas
Published
Categorized as angular, javascript, rxjs, typescript Tagged , , ,

Share data api with BehaviorSubject – architecture Observables Store

I would just like to make a call in the api and reuse the data in an observable, like a kind of store like in redux. API URL: http://demo5095413.mockable.io/consolidado Service responsible for connection with api @Injectable({ providedIn: ‘root’ }) export class ConsolidadoApi { constructor(private http: HttpClient) { } getInvestiments(): Observable<any> { return this.http.get<PosicaoConsolidada>(`${environment.basePosicaoConsolidada}`) .pipe( map(res […]

By Guilherme Lucas
Published
Categorized as angular, rxjs, typescript Tagged , ,

observable undefined in componet – Angular

I have a service that connects with api export class ConsolidadoApi { constructor(private http: HttpClient) { } getInvestiments(search?: any): Observable<any> { return this.http.get<any>(`${environment.basePosicaoConsolidada}`); } } Response this api: http://demo5095413.mockable.io/carteira-investimentos This one is responsible for the logic before reaching the component @Injectable({ providedIn: ‘root’ }) export class CoreService { public test; constructor(private api: ConsolidadoApi, private state: […]

By Guilherme Lucas
Published
Categorized as angular, javascript, rxjs, typescript Tagged , , ,

observable undefined in component – Angular

I have a service that connects with api export class ConsolidadoApi { constructor(private http: HttpClient) { } getInvestiments(search?: any): Observable<any> { return this.http.get<any>(`${environment.basePosicaoConsolidada}`); } } Response this api: https://demo5095413.mockable.io/consolidado This one is responsible for the logic before reaching the component @Injectable({ providedIn: ‘root’ }) export class CoreService { public test; constructor(private api: ConsolidadoApi, private state: […]

By Guilherme Lucas
Published
Categorized as angular, javascript, rxjs, typescript Tagged , , ,

observable undefinded in facade architeture with rxjs

I’m doing a poc to redesign an app in angular and I liked the idea of ​​separating the logic from the component, but I’m having the following problem. Service that connects with api @Injectable({ providedIn: ‘root’ }) export class ConsolidadoApi { constructor(private http: HttpClient) { } getInvestments(): Observable<any> { return this.http.get<any>(`${environment.basePosicaoConsolidada}`); } Core service where […]

Duplication of data in communication between components

I have two dropdwown(select in HTML) and I need to send the value of both when selected and send request. <app-dropdown-segment></app-dropdown-segment> <div>receiving data from the drop-segment: {{receivesSegment}}</div> <app-dropdown-lever></app-dropdown-lever> <div>receiving data from the drop-lever: {{receivesLever}}</div> But when I select an option it reflects the options chosen in the two interpolations: Dropdown-segment and dropdown-lever I’m doing the […]

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
faq