Questions tagged [rxjs-observables]
The rxjs-observables tag has no usage guidance.
571
questions
0
votes
1
answer
23
views
How does CombineLatest work compared to of
I'm learning about forkJoin. I'm trying to wrap my head around how it works compared to creating an observable with of. Please tell me if I have this right:
When I use of, it creates an observable ...
0
votes
0
answers
22
views
Failed to load resource rxjs
I just upgraded to rxjs 5.4.3 and now I am getting a error in the browser. In my package.json I have "rxjs": "5.4.3" installed so I am not sure why I am getting this error message?
...
1
vote
1
answer
33
views
Property 'lift' in type 'Subject<T>' is not assignable to the same property in base type 'Observable<T>'
I am getting this error about property lift in the Subject.d.ts file and not sure how to correct it. I am using RxJS version 5.0.1.
Error TS2416 (TS) Property 'lift' in type 'Subject<T>' is ...
1
vote
0
answers
34
views
Wait in nested observables
I'm new to Observables; I have to convert a nested for loop with Observables and, when a condition is meet, wait for a certain amount of time.
I was able to convert the for-loop with Observables, but ...
0
votes
1
answer
35
views
Wait for data from one observable to be used later
I have the following code in an angular component:
@Component({...})
export class ComponentOne implements OnDestroy, OnChanges {
readonly myBehaviourSub = new BehaviorSubject<Observable<...
0
votes
1
answer
24
views
How to filter an observable against object properties
I have an observable, fields$: Observable<Field[]>. I need to look at the required and result properties of each field to determine if all required fields have been populated.
I have another ...
0
votes
0
answers
16
views
Rx java response change?
I am new to rxjava this is what the api call function
Observable<JsonElement> call = mWebAPI.getClicktoCall(user_id,Record_id_separated2);
Disposable callProject = call.subscribeOn(...
0
votes
1
answer
33
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
32
views
Retry logic with different access token in Angular http client
I have access token and refresh token for an API. One user can have different refresh tokens for different API, and I don't know how to manage access token when access token is expired.
For now I ...
0
votes
0
answers
48
views
Source of forkjoin() not recognized as function
I'm using a ForkJoin to wait on 3 objects. Calling their getters inside the fork join seems not to work, giving the error seen below. The same method is called multiple times throughout the project, ...
1
vote
1
answer
53
views
rxjs retryWhen promise is resolved
I'm implementing an Angular service which calls a server for data. In every call I need to pass a token which lasts about a minute and then I need to map the response to get an specific field. So if ...
3
votes
1
answer
48
views
RxJS how to grab first values that is not null from two promises
I'm trying to wrap my head around how RxJS concat works, and how it works with Promises in general.
I have two observables:
currentConfirmation$ emits null
newConfirmation$ emits a new confirmation
...
0
votes
1
answer
26
views
NGRX Select returning Store not a value
catalogueSelection in Store Image
I have the data I require in state (catalogueSelection: searchTextResult & categoryCheckboxResult) and need to pass the string 'SearchTextResult' into one ...
3
votes
3
answers
40
views
RxJS: execute concatMap i parallel
Is it possible to execute a high-order observable in parallel, but still preserve the order when merging the results?
I have something looking like this:
invoker$: Observable<void>;
fetch: (...
0
votes
1
answer
29
views
Angular subscription to observable - only want value after request for it
I have a service that looks like this:
export class WebViewService {
private webViewMessage = new ReplaySubject<any>(1);
public webViewMessage$ = this.webViewMessage.asObservable();
...
1
vote
1
answer
35
views
Custom hook to subscribe to array of observables and take the latest value from each
I have an array of Observables streams$ which each emit a value once, when the associated async operation completes. I want to aggregate the results in an array arr, where arr[i] = undefined if ...
-1
votes
0
answers
34
views
How to unnest observables and prevent race conditions
I have the following that actually nest observables, and creating race conditions with errors in the process: How could I structure this code to make it work?
How can I refactor the code to use ...
1
vote
1
answer
37
views
Observable in hook dependency array causing infinite loop
I have a custom hook which receives an array of Observables as a parameter, then (in a useEffect hook) sets internal state any time the Observable emits a value.
export const myHook = (obs$: ...
0
votes
2
answers
56
views
Angular: Behavior Subject Value is not persisting in service
i've created 2 components "search-bar" and "search-results" and a shared service "search-results".
below is my code:
(NOTE): components do not have child and parent ...
0
votes
1
answer
31
views
How to make http post calls synchronously in Angular 12
I have a requirement to call an API using post method, depending on the response i need to further implement business logic.
Below is code snippet:
GetSuffixList(_LinesToMove: string[], ...
1
vote
2
answers
77
views
How get initial value from an Observable Angular 8+
I have a page form with values already setted, previous and next button elements.
At ngOnInit, I'm getting a List with 3 items from an observable, as initial value - sometimes I get 4 items.
Before I ...
-1
votes
1
answer
97
views
refresh the google ads (adsense) on angular route change
i m unable to refresh the google adsense on route change on layout component
here is my app-routing modue
//app-routing-module
{
path: '',
component: LayoutComponent,
children: [
...
1
vote
1
answer
33
views
Multiple subscriptions causing source stream to fire twice
I want to use RxJS to listen to clicks, perform a transaction, and keep track of the transaction status:
function performTransaction() {
const status = {
'0': 'pending',
'1': 'success'
}
...
1
vote
1
answer
28
views
expected behavior of immutability in rxjs observables
I've been troubleshooting a pretty nasty bug where I've eventually realized that it was caused by mutation of a nested object that was passed down the stream of observables and it really surprised me ...
1
vote
1
answer
35
views
How to load data from remote URI with nestjs/axios properly using Observables in the correct way?
NestJs suggests to use the HttpModule imported from @nestjs/axios to perform requests to external APIs. I understand that the HttpService transforms the responses into Observables. However, it makes ...
0
votes
1
answer
63
views
How to manage lots of BehaviourSubjects in angular component
Currently I'm working on some module in which we try to use approach with async pipes instead of markForCheck and so on.
Most of data is coming over HTTP, and approach in whole project is to use ...
0
votes
1
answer
233
views
ERROR TypeError: Cannot read properties of null (reading 'users') ngFor Change Detection
In my list-users.component.ts, I use private ref: ChangeDetectorRef here is the code below for reference.
export class ListUsersComponent implements OnInit {
public users: any[];
constructor(...
1
vote
2
answers
152
views
async template bind from subscribe angular 13
I'm trying to bind data on subscribe on ngOninit, here is the page profile.component.ts below.
export class ProfileComponent implements OnInit {
public userDetailsArr: UserDetails[] = [];
private ...
0
votes
2
answers
30
views
RxJS and optional inner query
I have a kind of web form which has 2 parts (master and optional child) and want to save the form values
A first call is for master data. The call result is used as a parameter for second call. But in ...
0
votes
1
answer
46
views
How to return data from a method in a service and subscribe to that method
My question is simple. I've a service where I have added one method called getBillingWeeks. This method will make a call to an API (indirectly) and it should return the correct data. My problem is ...
0
votes
1
answer
32
views
Race condition when using withLatestFrom as part of my pipeable operator
I have the following code that suffers from a race condition. Sometimes I can see the results, sometimes I cannot:
const op1 = ()=>{
const filesObs = from(['a','b','c']).pipe(delay(200))
...
2
votes
2
answers
75
views
Rxjs observable emit in order
how can i subscribe for example three observables, and to emit when one of them emit new value depend on the order they are, like forkJoin but emit but the order of them is important so if ob3 emit ...
2
votes
2
answers
91
views
Better alternative to using concatMap twice within pipe?
I want to execute a pre-defined promise (promise 2) recursively after another promise (promise 1) resolves to see when my connection to a peripheral device returns false, following which I can do ...
0
votes
1
answer
61
views
Is there any alternative rxjs operator for forkJoin to handle individual errors?
I am working on RxJS version 7 in my Angular project. I know that the forkJoin operator will wait for all the observables to complete and then it will emit the values. If any one of them fails, then ...
0
votes
1
answer
81
views
returning a rxjs observable from a function of a class that implements an adapter
I get the error:
Type 'Observable<string>' is missing the following properties from type 'Observable<string>': _isScalar, _trySubscribe, _subscribets(2416)
I abstracted the code I'm ...
-1
votes
3
answers
83
views
Auto-initialize BehaviorSubject to cache global data
Simplified use case:
I have Angular app with multiple modules, most (not all) of the modules use a list of airports
I want to create a global-cache.service.ts and cache the airport list in ...
0
votes
1
answer
214
views
lastValueFrom does not exist on type 'Observable<Object>'
I have updated RxJS to version 7. In this version toPromise is deprecated and should be replaced with firstValueFrom and lastValueFrom. I however get error when I do the replacement:
import { ...
0
votes
0
answers
58
views
Angular filter applying when the data is updated from an Observable
I've got an Angular 13 application which is a sort of dashboard which monitors ever-changing data. The data comes from a Websocket and adds/updates records in the table as it comes in, live. The table ...
0
votes
1
answer
43
views
How do I execute methods based on which observable is emitted? But at first, I need to depend on both the observables
combineLatest(data$, order$).subscribe(([data, order]: any) => {
if (order && data) {
this.setData(data);
this.setOrder(order);
}
});
The current scenario is that-we wait for ...
1
vote
1
answer
47
views
Rxjs using previous observable from early stage of the chain
How do I use an observable from early stage of the chain (not the last one).
I have code like this:
deleteGroceryStoreAndItsOwner() {
this.groceryStoreOwnerService.getGroceryStoreOwnerSummaries(...
0
votes
0
answers
88
views
.toPromise().then(...).catch(...).finally is not a function
I'm getting this error on Firefox and I'm using rxjs 6.5.4 version:
Unhandled promise rejection TypeError:
this.service.getPastData2(...).toPromise().then(...).catch(...).finally
is not a function
...
0
votes
1
answer
129
views
combineLatest with arrays of observables
How would one go about using combineLatest with two or more arrays of observables?
const array1 = [of(1), of(2)];
const array2 = [of(3), of(4)];
combineLatest(array1, array2)
.subscribe(([array1, ...
-1
votes
2
answers
134
views
How to filter through the post api response and get only the filtered array object from api response in angular?
I have this getSearchBank() post API and this is the response of this api .
This api gives me all the banks which are present in the database
(8) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {bankId: '...
0
votes
0
answers
74
views
Angular testing mock service function did not called
In my Angular project I have this Jasmine spec file:
describe('TagListComponent', () => {
let component: TagListComponent;
let fixture: ComponentFixture<TagListComponent>;
let ...
0
votes
0
answers
25
views
RXjs 7 : cannot read property ''findUser' of undefined
After updating rxjs 6 to rxjs 7 it's showing cannor read property 'findUser' of undefined
const {blCustomer, plCustomer}= await this.client.getClient().findUser({userId:id}).topromise()
How to ...
2
votes
5
answers
143
views
How to repeat a promise conditionally using rxjs
I would like to repeat an API call which returns a Promise, conditionally using rxjs.
The API method receives an id which will be changed on every call by adding a counter prefix to it. The calls will ...
0
votes
1
answer
61
views
Observable emits no value
I am new to Observables. I am using a switchMap to loop through an array of Observables from firestore, retriving two streams, combining the outputs of the streams into a new Observable Array.
...
0
votes
0
answers
26
views
Comparing 2 observable array object values and returning the filtered observable
need a little help her with observables again. I had 2 observables with the respective data structures below.
Observable 1
[{application: "", dateCreated: "",dateUpdated: "&...
1
vote
1
answer
34
views
RxJs mergeAll(), scan() coninutes to accumulate
I have this bit of code that is intended to accumulate features as they are added ot the features$$ observable.
private features$$: BehaviorSubject<Observable<Feature<FeatureConfig>>&...
1
vote
2
answers
87
views
RXJS, How to watch mouse and keyboard and do something when when none has been used for some time?
I need run a function if neither the mouse has moved, nor the keyboard has been touched for 1mn.
I tried the code below but doesn't seem to work.
How can I fix it?
Thank you for your help.
mouseEvent$ ...