As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [rxjs]

The Reactive Extensions for JavaScript (RxJS) is a set of libraries for composing asynchronous and event-based programs.

Filter by
Sorted by
Tagged with
0 votes
0 answers
52 views

Idle/inactivity tracking with RXJS

I needed to implement a way to track idle state / inactivity in a browser (Angular app), so I tried to create an observable that would trigger whenever there wasn't any user-interaction event, so the ...
vitaly-t's user avatar
0 votes
0 answers
27 views

Are there any implications of calling the same function recursively within a switchMap operator in RxJS?

In the code below, startFlow$ function that takes an input request object and subscribes to open a dialog/popup that performs a certain operation. Once the popup is ...
Chek Wei Tan's user avatar
0 votes
0 answers
28 views

What's the best way to separate concerns between different observable pipelines?

I've replicated the RxJS recipe for the alphabet invasion game. I would like to know the best way to code with Observables. ...
Federico Trotta's user avatar
0 votes
0 answers
49 views

Consecutive permission checks: forkjoin of calls made from an array of objects requiring 2 consecutive checks in backend, results in nested Observable

Bad Practice: Nested Observables I could use some help with preventing nested Observables, by using higher order ones somehow. I have some starting data (expected ...
H3AR7B3A7's user avatar
  • 229
1 vote
1 answer
109 views

Convert from get response to array of type

I would like to know if this is the best/most efficient/industry standard way of converting from the http response to an array of typed values: Type class: ...
Matt W's user avatar
  • 157
-1 votes
1 answer
634 views

If condition in combineLatest observables [closed]

I have many observables so I use combineLatest in RxJS. After get all results I need to check one of value by using if condition. If the condition meets then call ...
Love's user avatar
  • 369
1 vote
1 answer
62 views

Typescript error handler

I wrote a function in Typescript which takes required parameters, optional parameters and parameters with default value. I want to use this function for error handling of http requests. I am not sure, ...
Yusuf Ipek's user avatar
6 votes
1 answer
2k views

Custom RxJS operator to prevent duplicate API calls in Angular

I have a usecase where I want to prevent unexpected duplicate Http calls. I'm wondering if I can have a custom operator which can be used in pipe for any API as shown in below ...
knowhow's user avatar
  • 61
1 vote
2 answers
102 views

how to avoid nested asynchronous subscriptions in RxJS?

I got this two subjects that both have a delay and I need the second one to be subscribed when the first one is completed, asynchronously. Both subjects only emit once (http requests) and I'm trying ...
azerafati's user avatar
  • 131
0 votes
1 answer
68 views

A custom RxJS operator which emits (and completes) once a condition has been satisfied for all previous values of the source

The code is written in TypeScript. ...
Lazar Ljubenović's user avatar
2 votes
1 answer
123 views

Rxjs search in Angular

I created an rxjs search for a hiring company, but I got rejected for the following reason: -performance issue on a bigger data set. -bugs My question is how can I make this code better for the next ...
Gábor Pehl's user avatar
0 votes
1 answer
169 views

RxJs - Flat nested swithMaps and pass variables on Http interceptor

How can the following method be flattened? I tried to pipe all the operators to the first pipe (from(this.fireAuth.currentUser)) but I lost access to the previous ...
Olvis Camacho's user avatar
0 votes
1 answer
625 views

Handling a spinner for multiple REST calls

Context In an Angular application, I have three <select> boxes that are fed from the database with a relatively small data set. These boxes are part of a ...
usr-local-ΕΨΗΕΛΩΝ's user avatar
4 votes
2 answers
2k views

Angular10 RxJS - Interceptor to add/refresh JWT Token

I have a project, for which I use Tokenauthentication with JWT Tokens. I am relatively new to Angular Development and rxjs in particular, so there are a lot of concepts I am likely not yet familiar ...
Philipp Doerner's user avatar
2 votes
1 answer
1k views

Rewrite BehaviorSuject that takes either localStorage or Observable in Angular

I have this code ...
rst's user avatar
  • 207
0 votes
1 answer
522 views

Refactor multiple if condition in JavaScript/TypeScript

I want to refactor this code but am wondering how I should start it. I'm not sure this code is totally against clean code or not. I'm thinking to use RxJS or a JavaScript builtin method. I'd like to ...
DigguDg's user avatar
  • 63
1 vote
1 answer
3k views

Merge the multiple observables responses into a single array

Here's what I trying to do: Given a paginated API, get all the resources using parallel requests. The API returns a limited number of resources per call. So, you need to use an offset parameter to get ...
Adrian's user avatar
  • 111
2 votes
0 answers
38 views

Switching article states using state pattern

The Article model supports a bunch of transitions. Only two are shown below: star()/unstar()....
lexeme's user avatar
  • 121
4 votes
0 answers
770 views

RxJS - Prevent valueChange of one form control if another form group is dirty OR an HTTP error has occurred

I've recently started working on an Angular 7 project (I'm pretty new to Angular and RxJS), and I was requested to implement this new functionality: The Problem I have to implement a component to ...
user avatar
1 vote
0 answers
65 views

Angular8 & RxJs: handling Observable in interceptor

the following tutorial uses an interceptor to show/hide a loading bar: https://www.freakyjolly.com/http-global-loader-progress-bar-using-angular-interceptors/ ...
TeaCup's user avatar
  • 181
1 vote
1 answer
325 views

Typescript & rxJS group list of object by month/year and map to certain value

I have class: export class DayValue { date: string; status: string; } and statusToPointsMap: ...
Adrian's user avatar
  • 459
5 votes
0 answers
535 views

IndexDB (RxJs) - Angular Service

Inspired by Wrapping IndexDB with RxJs. (Edit - Added a Stackblitz example). My use case is a simple, on-disk temporary cache. No errors are propagated, null ...
Avi Kaminetzky's user avatar
2 votes
0 answers
55 views

Credit Card Form using RXjs

I am trying to improve my skills and I'd like to work on avoiding bad practices and mistakes. Can anyone skim over my code and point out what should have been implemented more efficiently or in a ...
Valary o's user avatar
  • 171
2 votes
1 answer
335 views

Is returning promise form angular service bad?

What is the problem when I return a promise from angular service instead of Observable? If it's a matter of any manipulation or side-effect, that I can easily do ...
Siraj M's user avatar
  • 115
1 vote
0 answers
73 views

Refactor this RXJS code

I have this angular service that is working perfectly but I'm feeling that it isn't very readable. How would you refactor it? (Simple tips as "try this instead of that..." are very welcome. I'm ...
J Rui Pinto's user avatar
4 votes
0 answers
466 views

RxJs memoized singleton selectors

I am working on an angular stack that has n amount of services that hold data in stores of this type: ...
Lars Holdaas's user avatar
1 vote
0 answers
30 views

Making code with interdependant observables reusable

Whenever I find myself repeating the same actions across different components in my projects, I immediately feel that I should extract the code to a function. The problem this time is that I can't ...
J Rui Pinto's user avatar
2 votes
0 answers
308 views

RxJs observables pipes SwitchMap and async with typealong search input

I'm using RxJs for type along search, I setup an observable to emit a value after 1 second so it behaves like http with delay. I subscribe to it via the async operator in the template, the component ...
doe's user avatar
  • 121
1 vote
0 answers
39 views

Processing the results of API calls and process data

I'm making use of RxJS and observables within my Angular application to process the results of API calls and process data. I've written the component and it works without any issues. However after ...
Jake12342134's user avatar
1 vote
1 answer
1k views

FormArray total of each formgroup via RxJS

Stackblitz - https://stackblitz.com/edit/angular-plp4rb-formarray-total-prs9ay I'm new to RxJS observables. I've created a form array where the total for a line is ...
Andrew Allen's user avatar
3 votes
0 answers
192 views

Implementing custom observable classes

I want to implement my own custom observable class so I can have a hierarchy of components and the closest defined configuration item bubbles to the front. ...
Adrian Brand's user avatar
5 votes
1 answer
46 views

Merging client names into orders using RxJS

I have an API which I can't modify. I have to use data as it is. I want to join data from two separate requests where the second request is based on data from the first one. I have a working ...
Lyczos's user avatar
  • 151
1 vote
0 answers
985 views

RxJS BehaviorSubject with asynchronous initial value

I am using RxJS to fetch a data structure from a server and cache it, but I also need to be able to overwrite the value locally (specifically, a user operation can change the server state, and the ...
Dave's user avatar
  • 211
1 vote
0 answers
12 views

RXJS and Ionic- Sequencial Subscriptions Waiting on User Action

In an Ionic App a user can open a new browser via "inAppBrowser". I'm trying to get the stats of the user before they go into to the inAppBrowser, get the stats again when browser closes, and then run ...
av0000's user avatar
  • 111
1 vote
0 answers
508 views

Angular Websocket service with wait for response sending

I am writing an Angular Websocket service that can send messages to a server and then can subscribe to the response. I am grateful for every suggestion to improve this. ...
Franki1986's user avatar
3 votes
0 answers
52 views

Caching different http-requests

There have been multiple discussions on caching http-requests with RXJS. In this question/proposal I want to propose a custom rxjs-operator (non-pure) to provide ...
Tobias Gassmann's user avatar
3 votes
0 answers
112 views

Fetching user information along with user posts in Angular

Here is my code with 2 services, one is messageService which is used to get user messages: ...
Alireza's user avatar
  • 91
2 votes
1 answer
142 views

List component using RXJS Angular

I have a small angular project, where I have an Article component to list articles with pagination system. The default page The placeholder loader page The main objectives are: Display the ...
ahmedbhs's user avatar
  • 121
5 votes
0 answers
5k views

Angular async pipe with loading spinner and manual refresh

I have an Angular 6 app with the following requirements: Get data from a web service. Load the data when the page is displayed. Reload the data when the user requests a reload by through some UI, ...
rveerd's user avatar
  • 151
2 votes
1 answer
88 views

JavaScript and RxJS Password Strength Indicator

This is my first time using RxJS (or any observable library). It seems to work okay but I'm not sure about best practices. The thing that I am most unsure about is subscribing to the observable ...
Matthew Smith's user avatar
3 votes
1 answer
923 views

Using RxJS Observables to mediate routes in nodejs

I am learning to be a full stack developer and have been building out an application using Node JS as a backend. Since I have lots of experience using Angular I love RxJS. So naturally I was tempted ...
Aaron's user avatar
  • 133
2 votes
1 answer
3k views

RXJS queue up multiple http requests and send when x conditions happens

Just started to use rxjs few weeks ago, I think I'm getting most of it right, but my code seems to be not that efficient and prone to bugs I haven't run into yet! I need to be able to send http ...
leseulsteve's user avatar
2 votes
2 answers
84 views

Counting quiz for children

I made a game for children. This game tests the ability to count (i.e. compare numbers based on magnitude). First you must select the age of the child in the upper menu, then you need to select blocks ...
cyklop77's user avatar
  • 291
1 vote
1 answer
42 views

Logging observable values while extending service

I'm trying to extend a service function which returns an Observable<T>. The idea is to extend the function so I can add logging functionality whenever the ...
Andreas Johansson's user avatar
3 votes
1 answer
243 views

Store first value of http request with rxjs but keep doing httprequest

With RXJS library : I need to store values from the FIRST http request, but keep doing other http request on demand. I have done this code so far, and that is working. But I think there is a more ...
Stefdelec's user avatar
  • 131
2 votes
1 answer
712 views

Changing http-requests conditionally

I'm new to RXJS and I have a working piece of code for http-request and subscribing to Observables from a shared service in Angular. This works, but I'd want to get rid of the nested subscriptions, ...
DRNR's user avatar
  • 129
1 vote
2 answers
972 views

Angular2/4 broadcast service using RxJS

I am no expert in RxJS as I am still learning my way around the new paradigm of Observable/Subject. I was trying to implement a broadcast service (based on NgRadio) that allows a new subscriber to ...
Codewarriro's user avatar
3 votes
1 answer
4k views

Chaining 3 dependent HTTP request subscriptions one, which is polling

Here is a function that triggers after selecting from a dropdown to choose the floor. As you can see, there are 3 levels of API calls (regular HTTP GET requests with JSON responses) that chain ...
jim's user avatar
  • 31
10 votes
2 answers
25k views

RxJS Observable with initial value

Is it possible to get rid of the BehaviourSubject to have an Observable with an initial value? Another thing I don't like is that I'm using getValue() and then modify this value and push it with next ...
seveves's user avatar
  • 373
1 vote
1 answer
3k views

Angular 2 / rxjs chaining HTTP calls

I have a registration form. Step 1 user creates an account. As user creates an account I need to authenticate user with the created account. in my account.service.ts I have following. Is this the ...
MonteCristo's user avatar