Questions tagged [rxjs]
RxJS is a library for reactive programming using Observables, to make it easier to compose asynchronous or callback-based code.
18,893
questions
0
votes
0
answers
18
views
How to dispatch api response data into ngrx store from a ngrx effect service
I'm struggling to dispatch data to the ngrx store after data is fetched from Api. I actually have a ngrx effect service loginEffect.ts as bellow :
constructor(private actions$: Actions, private ...
0
votes
1
answer
14
views
Angular 11 finalize is not called when the subject type value emitted is null and not processed in switchmap
I have a subject which emits a string value and the code is as below: when the components get initialized, the subjectTypeSubject is null. But there is another method in a component get subscribed ...
0
votes
1
answer
36
views
How to create a Subject in rxJS that changes the value after timeout?
I have a snackbar subject implemented like this, where a message shall appear for 4 seconds in an Angular app:
snackbar = new BehaviorSubject<string | null>(null);
showMessage(message: ...
0
votes
1
answer
31
views
Why does unsubscribe cancels current concatMap which is performing http request?
This is my code:
// showing code of FileUploadService
private uploadFilesSubscription?: Subscription;
...
// end upload of files
public stop(): void {
this.uploadFilesSubscription?.unsubscribe();
}...
2
votes
2
answers
40
views
Rxjs Observable: Get HTTP data only for the first subscriber and cached data for the rest
I'm trying to implement user permissions in an Angular app, but to put it simple, this is the scenario:
Upon loading a MainModule, I make an HTTP request and store the data in the localStorage, so the ...
0
votes
1
answer
23
views
Firestore sorted list - Repeat API call to Firestore X times to iterate over a linked list of Firestore documents
I am experimenting with a "linked list" in Firestore that maintains a sorted list of transactions. I am expecting a high volume of transactions and so I am playing around with the idea of an ...
0
votes
0
answers
10
views
hammerjs pan won't let drag an element back to starting point
I am trying to familiarize myself with hammerjs. For a start I took a panning example that I googled up and started to adjust it (horizontal scroll only, using css translate, rxjs).
I came up with the ...
1
vote
2
answers
42
views
Determining the order within subscribe()
I have a function in my component.ts file. What I want to do is to make sure that uploadFile() operation is completed before this.isModalOpen=false , this.form.reset() and this.list.get() are ...
0
votes
2
answers
28
views
how can i convert async/await code to rxjs(observable)?
there are many codes in my projects that using async/await. but i want to exhange all them to rxjs code.
But I'm not used to rxjs. Please tell me about the pattern or method of converting the async/...
0
votes
1
answer
53
views
How to check a property in an ngFor loop using an observable
There is this list of card objects that are returned from an API.
One of the cards should be set inactive. In the card component that is done via an observable:
@Component({
selector: "app-card&...
0
votes
1
answer
35
views
How to redirect from ngrx effects loginEffects to dashboard after login success
I'm using ngrx and ngrx effects to implement my login system. The login service makes an api call and the the response is success OK. But user is not redirected to dashboard even though redux devtools ...
0
votes
1
answer
28
views
subscribe observable (as subject)
i have following example code which returns id+1 of it's elements:
EntitiesService:
public create(model: Model): Observable<number> {
var subject = new Subject<number>();
...
0
votes
1
answer
24
views
Module '"rxjs"' has no exported member 'firstValueFrom'
App.service file looks like this:
import { Injectable } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { Observable, firstValueFrom } from 'rxjs';
// import { ...
1
vote
1
answer
42
views
combineLatest but remove completed observables
How can I combine the latest values but remove the completed observables dynamically? The combineLatest operator does not remove completed observables, it just repeats the last value they emitted ...
2
votes
1
answer
44
views
Is there a name to this common state manegement pattern with rxjs? Does it have limitations?
In Angular applications, we typically do something like this to manage shared states:
import { BehaviorSubject } from 'rxjs';
interface User {
id: number;
}
class UserService {
private _users$ = ...
0
votes
1
answer
41
views
API call returns empty object when called from inside Angular service
I'm getting this only when I subscribe to the function that makes api call from inside the Angular service, so the object that subscribes to the function is empty. Here's my code snippet from my ...
0
votes
0
answers
19
views
How do I upload multiple files in array in Angulars reactive forms, from an API and send the data as a number to the array
***ERROR IMAGE: *** https://ibb.co/JKd0hV3
Who can help me solve this problem, I get a 490error whenever I run this code. Am I missing something or need to refacture something. I need to upload ...
0
votes
3
answers
52
views
Use an observable inside of an interceptor
I want to write an interceptor to add an auth token to all the requests. My token comes from a lib, angularx-social-login, that only provides an Observable to get the token. So I wrote this but my ...
0
votes
1
answer
28
views
How to update the source when use retrywhen RxJs
I'm doing a request to an API to create an order, it's probably got an error when trying to create the order with the same code because the method generateCode() is a random generator!
When performing ...
0
votes
1
answer
23
views
rxjs date range picker always wait for start and end observables
I have an angular material date picker and i'm trying get the start date and end date observables before I submit my query
component.html
<mat-form-field>
<mat-label>Date ...
0
votes
2
answers
52
views
angular and rxjs - removing properties from object
I have an endpoint that returns the following object properties:
{
"id": "1",
"department": "sample",
"address": "sample",
"...
0
votes
0
answers
16
views
WebSocket from HTTPS website to different port, self-signed certificate
I am facing issues when trying to connect from a browser via WebSocket to a server.
Website is hosted on a default port (80, 443, configurable - this is s selfhosted intranet application for multiple ...
0
votes
0
answers
18
views
Angular 11: core.js:1141 Uncaught Error: Type DecoratorFactory does not have 'ɵmod' property. at getNgModuleDef (core.js:1141:15)
The project (Angular 11, rxjs, material, @swimlane/ngxdatatabe) can be build and serve with no error message.
When loading the landing page from Chrome, it is stuck and console shows the following ...
0
votes
1
answer
30
views
How to receive a type from Angular 12 reactive dropdown list when change fired
in an Angular 12 reactive form, I have a dropdown list which is hooked up to fire on the change event.
Now the data populating the D/D is of a Type rather than just a list of strings.
When it returns ...
2
votes
1
answer
33
views
Angular combinelatest using subject without initial value
I am using Angular RXJS, I have multiple Behavior Subjects,
My problem is: I want the posts$ stream to emit initially without setting a value for the category filter when loading the page, but I don't ...
1
vote
2
answers
34
views
how to gracefully combine two Observables inside RXJS pipe
I'm building a log viewer with Angular.
When a user enters the page I need to load historical logs and start watching for new ones.
User can filter logs with a simple form that emits a query object. ...
0
votes
1
answer
17
views
ngrx selector return same values multiple times
I have a
export const selectIDs = creteSelector(
selectorFeature,
(feature: Feature) => {
return feature?.metadata?.ids || []
}
}
in the component I have
this.store.select(...
0
votes
2
answers
39
views
Rxjs, retry 3 times, wait 30 seconds, then repeat
I'm using rxjs to connect to a WebSocket service, and in case of failure, I want to retry 3 times, wait 30 seconds, then repeat infinitely, how can I do this?
0
votes
0
answers
15
views
RXJS net::ERR_INSUFFICIENT_RESOURCES
I am trying to make 3000 api calls all at once with rxjs.
I have read and researched all over the place but I cannot find any way of doing it without getting this net error.
1
vote
1
answer
13
views
Property 'subscribe' does not exist on type 'void'.ts(2339).Am getting this error
I am new in angular and am getting this error while implementing subscribe function after calling it from the service.This is component.ts file
OnSubmit(){
this.formModal.email=this.profileForm....
0
votes
2
answers
24
views
Why property does not exist on type in rxjs pipe function?
Why I losing the type in my pipe function? How to fix that?
Property 'n' does not exist on type '{}'
stackblitz
import { of, map, Observable, Subject, pipe, tap } from 'rxjs';
import { exhaustMap, ...
0
votes
1
answer
20
views
Take once only when a boolean changes from false to true
I have multiple boolean properties which are false by default, but that may only be set to true at the start of the application. Should the property become true, I should take action once and then ...
1
vote
1
answer
43
views
Angular RXJS Make multiple http parallel calls after first request get done
After receiving the initial request response, I need to perform three parallel requests in my ngrx Effect.
I implemented the following, however when I inspect it using the network tab, all three ...
1
vote
1
answer
22
views
Angular 11 switchmap not working after catch error
I have two dropdowns in my angular app. Second one is populated based on first dropdown value. I am using switchmap. It works fine as long as there is no error. As soon there is no values to populate ...
0
votes
1
answer
30
views
How to get arguments in a flat way with withLatestFrom in rxjs?
Is it possible to get the arguments of tap function not nested? like some of those ways:
tap(([foo, bar, baz]) => {
or:
tap((foo, bar, baz) => {
or:
tap(({foo, bar, baz}) => {
Because I ...
0
votes
1
answer
20
views
First page takes a very long time to load in angular universal (SSR) mode
I'm having a little problem with the initial loading of my site. I found the cause, but I don't quite know how to eliminate it.
I'm using angular 13 fired in SSR mode (angular universal)
So here goes:
...
1
vote
3
answers
38
views
rxjs: any "joining" alternative to withLatestFrom operator?
observable1.pipe(
withLatestFrom(observable2),
.. do something with both emitted observable values
)
Problem with withLatestFrom is that if observable2 hasn't emitted any event before the ...
1
vote
2
answers
31
views
How to run subject after error happens in rxjs?
Why subject.next(2); not works? I know it may happens because the signal stream got error.
But I add catchError and I return a EMPTY in the pipeline and it make it complete.
So seems catchError not ...
0
votes
2
answers
40
views
sequencing/queuing http request batches with rxjs
I'm trying to figure out how to queue outgoing api request batches using RxJs.
My goal on this sample angular app is to simultaneously send out 3 "random-cat-facts" API requests and only ...
0
votes
2
answers
27
views
ts Subject is not assignable to method's
I am getting a build error message ts2684 'this' context of type 'Subject' is not assignable to method'. I am import Subject from rxjs and then creating a property onSentenceChangeDebouncer. In the ...
0
votes
1
answer
29
views
RxJS subcribe is deprecated
I have trouble with subcribe method. In vscode it says that subcribe is deprecated but I have no clue how to change it properly.
public getAccount(): void{
this.accountService.getAccounts()....
0
votes
1
answer
43
views
Why can't I map a boolean response from http request in Angular?
I am calling a .Net method in my WebAPI from Angular, which sends a boolean to switch something off and returns a boolean with the current status. However when trying to map the response in Angular ...
2
votes
1
answer
41
views
How to do `unsubscribe` when I got error in the pipeline of rxjs?
How to do unsubscribe when I got error in the pipeline?
I do subscribe to the subjectPipe pipeline outside doWork function.
Inside doWork function I throw an error (can be as part of my logic flow).
...
0
votes
0
answers
7
views
Angular app initializer chrome not redirecting to login page
I am using app_initializer in my angular to check for authorization details. If unauthenticated, redirecting to login page. It works perfectly fine locally and in test environment using Firefox. But ...
1
vote
1
answer
20
views
Angular unit test pipe is not a function when subscribe observable from a service
I'm writing a unit test to subscribe observable from a service. I'm getting pipe is not a function error. I have created a jest spy for fundsListByClientId$ and simply returned the mock data. Please ...
0
votes
0
answers
32
views
Code mod/shift to refactor rxjs subscribe method
Does anyone have or know of a code mod or refactoring plugin for VS Code that will refactor multiple subscribe arguments into one argument object? I have many existing observables using multiple ...
1
vote
0
answers
37
views
How to know when the effect is done within effect in ngrx component store (rxjs flow)?
I'm currently implementing a feature that "open a dialog"(effect), after the dialog open the user hit save and then I want to close the dialog.
I made fake dialog and flow for the example.
I ...
0
votes
0
answers
28
views
Wait for QueryParams, Inputs and Subscriptions
It's been several times where I have coded solutions followed by 1000 fixes when in an Angular project I find myself having to listen to several events spread over time due to Angular life cycles, ...
1
vote
1
answer
18
views
Why does set state only work once within a subscription to an observable?
I'm now learning rxjs and want to use it in react.But there is a question confuse me.Below is a piece of code which I want to setstate in the subscription,but it only work once when mousedown is ...
0
votes
5
answers
52
views
How to get results from functions that use concatMap in rxjs?
I calling to two functions: fn1 and fn2. I use concatMap to invoke other after the other.
I don't use exhustMap and switchMap because they lead to nested "callback-hell".
exhaustMap(() =&...