Questions tagged [rxjs5]
The 5th version of the reactive extensions for javascript.
1,503
questions
0
votes
2
answers
49
views
How do I combine two subscriptions in Angular?
Is there a way to combine the subscriptions for this.controls.attendanceDate and this.controls.type? I need to have access to both at the same time in order to call each of this....
0
votes
2
answers
34
views
RxJS operator equivalent of ((observableX | async) || (observableY | async)) in template
I have the following code in my component template
<mat-spinner *ngIf="((facade.user.data$.isLoading | async) || (facade.product.data$.isLoading | async))"></mat-spinner>
I want ...
-1
votes
1
answer
39
views
Call a method from inside of subscribe
Im trying to call a method from inside of subscribe in angular/ionic. But its not working. Here is my code:
somemethod()
{
const browser = this.iab.create('https://someurl.com');
browser.on('...
1
vote
1
answer
100
views
Angular: intercept an HttpResponse and make other calls before propagate the response to caller
What i'm trying to do is to intercept a response and if here is a certain value (CHALLENGE), make a call to an other API and retry it 3 times if needed, then, if success, reply the first call and ...
0
votes
0
answers
51
views
Subject import package difference
I got a warning when I serve my Angular app.
depends on 'rxjs/internal/Subject'. CommonJS or AMD dependencies can cause optimization bailouts.
But when I changed Subject import package.The warning ...
0
votes
2
answers
145
views
how to flatten the nested array in rxjs
I am using forkJoin to subscribe multiple inner observable. How can I flat nested array to single level array.
const x$ = of([1, 2, 3, 4]);
const y$ = of([2, 4]);
x$.pipe(
switchMap((t) => {
...
1
vote
1
answer
179
views
Map behavioursubject and assign it to same variable after mapping rxjs
I have a scenario, my child component takes BehaviourSubject as Input and that(child) subscribes it internally.
I need to filter/map on BehaviourSubject in the parent, so that when somewhere next() is ...
-1
votes
1
answer
28
views
How to get data from second stream by first?
I have tried to get data from BehSubject this.visible$ only in case when this.redraw$ happends.
It works, but if the this.visible$ is changed somewhere the prev stream again works. How to avoid it?
...
0
votes
0
answers
97
views
Remove item from Observable<any[]> Angular autocomplete with dropdown
I have implemented autocomplete research in my Angular project. I am now trying to remove the list from the dropdown when option is selected. Problem is I am getting my data async so my data is a ...
0
votes
1
answer
156
views
Swicthmap in rxjs doesnt cancel the previous request
I am basically calling an API on keyup event of a textbox using switchmap. The problem that I am facing is that switchmap doesn't cancel the previous ongoing API call when a new API call is made
...
2
votes
1
answer
68
views
How can I make an Alert appear in the screen using AG Grid and Adaptable/
I created an Observable Alert in AG Grid (using Adaptable) which is correctly firing when an order is stale for 2 minutes.
But I only see the Alert in the Toolbar and not as a popup notification in ...
1
vote
1
answer
72
views
What's the added value of using Observable over normal Array? [closed]
I've been using Observables in Angular in the state layer to store the app data and to share that data among the components of the app. With a belief, using observables, that data would passively ...
0
votes
1
answer
157
views
Avoiding duplicate calls inside keyup event in angular
What i am trying to do is
call a service and bind the data on ngOnit()
In the given textbox, when a user types something, instead of calling API call for every letter, wait for a second, if user ...
1
vote
1
answer
129
views
debounce request on button click with angular
I'm finding it hard to implement debounce on an HTTP request with Rxjs once a button is clicked. What I'm trying to achieve is when the button is click, it should wait for x seconds before the post is ...
0
votes
1
answer
35
views
Angular data not loading
Angular also goes into the "first" place when I get data from the service. However, without clicking any button on the page, it does not enter the place where I write "second".
...
1
vote
1
answer
151
views
How to put custom gap between interval for polling in Rxjs angular?
I would like to implement gap / delay between every interval call,
i have tried below but it seems not working.
pollOnInterval(threshold = 4000): Observable<any> {
let thresholdValue = ...
0
votes
2
answers
31
views
How can i combine my RXJS expressions that represents two different logic?
Hi I am having an angular2 project.
I have two rxjs expressions. how can i combine both of them . the following is my rxjs expressions.
this.trafficTypeControl.valueChanges
.pipe(
filter(...
0
votes
1
answer
67
views
Issue with asynchronous angular requests
How to handle asynchronous calls in angular. I know i am getting array as undefined due to asynchronous nature but how do i solve it
private fetchData(id){
var array = [];
this.httpClient.get('...
1
vote
2
answers
298
views
RxJS group by field and return new observable
I've following interfaces and Observable<Machine[]>, what I want to achive is group by Machine symbol property in Observable<Machine[]> and return mapped observable Observable<Order[]&...
0
votes
1
answer
122
views
BehaviorSubject not working as expected Angular
I am trying to pass an email from accountrecovery component to password-reset component with BehaviorSubject but Im not receiving the email in password-reset component instead I get the initial value. ...
0
votes
1
answer
35
views
Abort promise chain upon action dispatch (rxjs)
Here is what I want to achieve:
this.jobManager
.queue(
// start a job
)
.then(
// do more stuff, but abort if `ABORT` action dispatched before it finishes
)
....
1
vote
1
answer
187
views
Cancel repeated subscription in mergeMap
How to combine the distinct, switchMap and mergeMap operators, so that when the source emits repeated values (detected by distinct.keySelector), the previous subscription is canceled (as in the ...
0
votes
1
answer
994
views
Subscribe to one observable twice from a component doesn't work
I got several components subscribing to my data service and they are all working fine. But in one of my components, I try to subscribe twice (inside ngOnInit and ngAfterViewInit) but this doesn't work....
1
vote
1
answer
191
views
RxJS - How to incrementally increase the delay time without using interval?
I want to incrementally increase the delay for this:
const source = from(839283, 1123123, 63527, 4412454); // note: this is random
const spread = source.pipe(concatMap(value => of(value).pipe(delay(...
1
vote
1
answer
41
views
How to concat multiple array observables that some might not emit any stream
Let's say I have following situation:
allItems$: <(TypeA | TypeB)[]>;
arr1$: TypeA[]; // [{a: 1, b: 2}, {a: 3, b: 4}]
arr2$: TypeA[];
arr3$: TypeB[]; // [{ b:1, c: 2}, { b:3, c: 4}]
arr4$: TypeB[...
0
votes
2
answers
172
views
subscribing when mouseover on particular element in the DOM
I need to subscribe & do some actions, when mouseover on particular elements in the DOM.
For Example: home.component.html
<div class="container">
<div ...
1
vote
1
answer
74
views
RxJs 5 of.filter.mapTo operators -> RxJs 6
I've inherited some old RxJs 5 code that smells awkward:
myFunc = (tag: TagModel): Observable<TagModel> => {
try {
const foundTag = this.mappedTags.find((x) => {
return ...
0
votes
1
answer
73
views
rxjs : get duplicate http requests on the first set that I send
I made this functionality, each iteration i have 7 requests that sent each environment.dashboard.frequency time,
but at the beginning, I see that i send 14 requests to the server instead of 7 :
let ...
1
vote
1
answer
137
views
undefined output while using mergeMap in Rxjs
Theoretically, I know what mergeMap is and how it works, but when I try to understand using
practical approach I get confused, this is what I have done so far
const input1$= of("value 1",&...
0
votes
0
answers
23
views
Using RXJS 5 for Paginating a Search [duplicate]
I'm trying to paginate a search and I need to prevent it from concatenating the list of results from the previous search.
Ex Search: %Dog%
1st page of results:
"Dog Barks", "Dog Growls&...
0
votes
2
answers
128
views
How do I map a list of objects from an HTTP API to a list of strings? [closed]
I am trying to use the merge operator is given below. I want to put only 'Mr' before login but I am getting an error, your help is much appreciated, thank you
let data=this.http.get('https://api....
0
votes
0
answers
91
views
RXJS Share state between merge streams
I need to make API call for get/set method. But these Service need previous state to make a next call.
In this pattern, in state prop I wanted to maintain previous state of this stream so that when I ...
0
votes
2
answers
143
views
How to smooth stream Rxjs?
I have a Rxjs:
private loading = new BehaviorSubject(false);
The loading can be changed fast from true to false. How to smooth this stream and pass values only if time between false and true is ...
0
votes
1
answer
151
views
spyOn(Observable, 'fromEvent') throws error after upgrading to rxjs 6.5
getInactiveTimerTabSynchronizer() {
return fromEvent(window, 'storage').pipe(
filter((x: StorageEvent) => {
return x.key === this.inactivityTabSynchronizerStorageKey;
}),
...
-1
votes
1
answer
21
views
How to improve Rxjs statement?
I have the following Rxjs statement:
const versionsRequest2$ = (num: string) =>
request2$(num).pipe(
map((versions) => {
const p = new P();
...
-1
votes
1
answer
50
views
How to send requests to server one after one RxJS?
How to correctly send RxJS requests, when there are 4 different API endpoints, I need to request each endpoint until previous does not return data.
Schema is:
Request 1 -> Return Void
Request 2 -&...
-1
votes
1
answer
24
views
How to call forkJoin in switchOperator?
I have tried to call forkJoin in switchMap:
this.route.params.pipe(
pluck('cadnum'),
tap((cadnum) => {
this.r1.repositoryModel.findallversionbycadnum.model.cadnum = cadnum;
this.r2....
2
votes
1
answer
205
views
complicated pipe chain with the HttpClient in Angular with RxJS
I dont have a lot experience in RxJS and I want to do the following thing with a RxJS pipe in my Angular service.
I tried with the iif function but I simply have not enough experience in it.
Angular ...
0
votes
1
answer
144
views
Creating multiple async pipes of unknown number
I am using Angular 5 and loading a list of items using a selector with my NGRX library. My selector returs a list of items which I used to dynamically create tabs on a page using the async pipe. Now, ...
1
vote
1
answer
49
views
Managing subscriptions based on async event
Im looking a way to simplify this and avoid managing subscriptions inside my pipe.
The general idea abought my code:
this.start$ubject // waiting for users call to start
.pipe(
mergeMap(() =&...
2
votes
1
answer
881
views
How to test with the marble approach when the returm is a EMPTY observable in effect?
I am using EMPTY from rxjs in order to handle the catchError, What is the correct value for expected in order to pass the fail scenario.
import { Injectable } from '@angular/core';
import { Actions, ...
1
vote
2
answers
119
views
How to use TypeScript in RxJs (BehaviourSubject) for strict type checking?
I am trying to create a BehaviourSubject using RxJs. Here in this code
import { BehaviourSubject } from 'rxjs';
const name = new BehaviourSubject("Dog");
// Here in the subscribe callback, I am ...
0
votes
1
answer
63
views
Confusion using Observable.switch
The switch documentation on github contains an example on how to use the command.
var source = Rx.Observable.range(0, 3)
.select(function (x) { return Rx.Observable.range(x, 3); })
.switch();
var ...
0
votes
1
answer
24
views
Delay is not working for obserber passing delay time?
I have custom function:
activate(seconds: number) {
of(true)
.pipe(delay(seconds))
.subscribe(
() => {
console.log("Run...");
},
(error) => ...
-1
votes
1
answer
47
views
How to run observer if no result from forkJoin?
I need to run observer if after one second there is no result from forkJoin:
of().pipe(delay(1000), skipUntil(!forkJoin$))
.subscribe(());
It does not work for me...
0
votes
2
answers
60
views
combineLatest is not getting called
I have the following code
I am new to rjxs programming so wondering what can be the root cause. I am trying to do a certain task and first combine all latest result, then subscribe to assign results. ...
0
votes
1
answer
384
views
Return object inside switchMap
I am new to rjxs programming so wondering how can I do the following.
const downloadUrls$: any = filelist.map((file: any) => {
const fileName = ...
const path = ...
const ...
0
votes
1
answer
128
views
behaviour subject and observable in Angular8
I have get rest service data call that is called 3 times. I need to create a data service to reduce the call to once so it keeps a local copy.if the copy hasn't been populated yet, it hits the api to ...
2
votes
0
answers
146
views
RxJS - Convert promise chain to observable not working
I'm trying to convert promise chaining:
this.tradeTypesLogicService.getList().$promise
.then(this.filterTradeTypes)
.then(this.setSelectedTradeType)
to an rxjs observable:
this....
1
vote
5
answers
335
views
How to remove the redundant requests in RXJS?
I am working on a front-end project with Rxjs and Angular Framework and I want to get json data from a api "api/data_processor_classlib.php....". There are three parts was subscribed the pipe this....