Questions tagged [rxjs-observables]
759 questions
2
votes
4 answers
What is the best way to use observables for http requests in angular?
I have got an Angular app that gets data from APIs.
So first my code for detail.component.ts looked kind of like this:
//code
getData()
{
this.http.get(url1).subscribe(data1 =>
{/*code: apply certain filter to get a filtered array…
user11962606
2
votes
1 answer
ApplicationRef.isStable not executing
I'm attempting to write a service that measures the completion time of the app becoming stable. Here's the service:
measure.service.ts
import { ApplicationRef, Injectable } from "@angular/core";
import { first, map } from…

a11smiles
- 1,190
- 1
- 9
- 21
2
votes
1 answer
TypeError: _rxjs.Observable.fromPromise is not a function
I use rxjs in React Native. I call Observable.fromPromise(storage.load({key: key})).map(() => value); shows the error.
My rxjs version:
"rxjs": "^6.5.3",
"rxjs-compat": "^6.5.3",
I have three steps.
Step1:
rxInit().flatMap(() => {
console.log('I…

Morton
- 5,380
- 18
- 63
- 118
2
votes
1 answer
How to await an asynchonous method defined inside subscribe before to complete an Rxjs Observable?
Let's take the code bellow:
myObservable.subscribe({
next: async () => {
await something();
},
complete: () => {
console.log('All async task are comlpeted');
}
});
The problem is that the console.log is called after the last next…

Alexandre Annic
- 9,942
- 5
- 36
- 50
1
vote
2 answers
Combining two observables even if one of them is empty and returning them as one observable
Currently I have a method that makes 2 separate calls to an API, each returns an observable and in the case that nothing is returned, the observable is set to EMPTY.
I'm currently trying to combine these returned observables and return the combined…

Lewis Patterson
- 21
- 1
1
vote
1 answer
Is there a `combineSoonest()` equivalent operator for RxJS that Emits all values as soon as any observable triggers?
I have two forms on my page, and I want both of them to be valid before showing the save button. I was looking for something along the lines of:
combineSoonest([
this.nameForm.statusChanges,
this.addressForm.statusChanges,
]).pipe(
…

cadesalaberry
- 612
- 1
- 8
- 17
1
vote
1 answer
Angular - Handle HTTP response with DTO
I can't seem to find a complete example of how to handle a complex Angular HTTP response.
I am using Angular 16.
The backend API I am trying to communicate with supplies a DTO (Data Transfer Object) like this:
{
"data": {
"name": "joe",
…

Scottish Smile
- 455
- 7
- 22
1
vote
3 answers
Is this a correct way of using forkJoin and mergeMap?
I need to make all requests in parallel whenever it's possible. Here is the simplified version of my code:
const arr = [
'https://jsonplaceholder.typicode.com/users/1',
'https://jsonplaceholder.typicode.com/users/2',
…

Noob
- 2,247
- 4
- 20
- 31
1
vote
0 answers
RxJS and HTML Geolocation API Return POSITION_UNAVAILABLE After First Location Update
I'm attempting to observe a user's current geolocation. I'm using the Google Chrome browser and altering the location in the developer tools for debugging purposes.
I don't have an SSL connection, so I added my URL to the "Insecure origins treated…

BR75
- 633
- 7
- 25
1
vote
1 answer
How to, inside subscribe method, assign value to parameter and then retrive that value from anywhere inside the Component?
How to, inside Service method (getTasksByCategory) which role is to assign result value to one
of the Component parameters, assign that value to parameter and then retirve taht value from
anywhere inside the Component?
This is my code:…

Piotr Deja
- 31
- 1
- 6
1
vote
1 answer
ConcatMap with CombineLatest creating more calls than expected
I have an ngrx action/effect that takes a FileList and uploads them sequentially to the server. After the first File is uploaded, an ID will be generated that needs to be used by the second File as argument, so it can be later related to the first…

Luis Lavieri
- 4,064
- 6
- 39
- 69
1
vote
1 answer
RXJS observers slow down each other
I have the page with the documents list on the left (with clickable items, each items will select a document), and the actual content of the selected document in the right side, which takes up the bigger part of the page. The problem is that when a…

Vladimir Despotovic
- 3,200
- 2
- 30
- 58
1
vote
1 answer
How do I resubmit an action stream observable after a failed attempt in Angular/RxJS?
Please ignore variable names and formatting as I've just changed them.
I've been trying to implement RxJS error handling for an observable that takes an action (user click) and then sends the request object from our form and passes that to an HTTP…

Donald Groezinger
- 25
- 5
1
vote
1 answer
Type 'Subscription' is missing the following properties from type 'Observable' : source, operator, lift, subscribe, and 3 more
Have issues assigning an Observable to Observable.
fetchContactLocationStates()
{
this.contactLocationStates$ = this.enumValues$
.pipe(takeUntil(this.destroy$))
.subscribe(x => x.filter((p) => p.CategoryId ===…

CorrieJanse
- 2,374
- 1
- 6
- 23
1
vote
1 answer
Subscribe to observable returns undefined
So I have a service that uses a dictionary to store HTTP responses (maps an id to a specific URL).
import { HttpClient} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
@Injectable({
…

inquisitivemongoose
- 340
- 4
- 12