19 questions
40
votes
3
answers
28k
views
What is the difference between throttleTime vs debounceTime in RxJS and when to choose which?
I'm trying to understand throttleTime vs debounceTime and which one is to be used when?
I have an upvote button that makes an API request to the backend (which counts the votes). User can submit ...
18
votes
5
answers
7k
views
How to reset a RXJS scan operator based on another Observable
I have a component which triggers an onScrollEnd event when the last item in a virtual list is rendered. This event will do a new API request to fetch the next page and merge them with the previous ...
16
votes
1
answer
32k
views
RXJS How do I use the result of one observable in another (and then process those two results together)
A very common problem when using RxJs seems to be to want the result of one or more observables to then use them in subsequent ones.
e.g. in pseudo-code (This is not rx or valid js syntax ...
1
vote
2
answers
274
views
rxjs Observable mixed with pre-resolved data
I have two observable data streams. One retrieves an account, one gets permissions.
What I need to do is check if the current user has the role of admin, or has the role of external and the current ...
25
votes
1
answer
18k
views
RxJS / Angular Observables use 1 or multiple pipes?
Having the following (just a quick example):
observable.pipe(map( s => s.anything ))
.pipe(filter(t => t > 5))
.pipe(map( t => t+5))
.subscribe( XXX )
Why ...
4
votes
2
answers
3k
views
RxJS: Even if used `shareReplay()` on source observable, `throwError()` gets executed separately for each observable
I'm using RxJS shareReplay() operator on an observable (courses$) to share observable stream among other two observables (beginnerCourses$ and advancedCourses$). It's working fine and single API call ...
4
votes
2
answers
2k
views
Order of execution with rxjs asapscheduler
Considering I have the following code:
let Rx = window['rxjs'];
const { of,
queueScheduler,
asapScheduler,
asyncScheduler,
animationFrameScheduler
} = Rx;
const { observeOn, tap } =...
4
votes
3
answers
3k
views
RxJs: Can you spread operators as arguments into pipe operator
I have two observable streams which do very separate mapping logic, but then ultimately end with following 3 operators:
this.selection
.pipe(
..Custom mapping operators
tap(_ => ...
4
votes
1
answer
5k
views
Utilizing rxjs repeatWhen in http request pipe in order to repeat the request if desired response is not returned
I'm trying to use below simplified version of my http request pipeline to ensure that if my response does not have the required data in res.myCondition to utlize repeatWhen and make another call, but ...
4
votes
1
answer
2k
views
Type guard for verifying that each item of an array is defined
I was wondering if it's possible to create a type guard which checks if every item of an array is defined. I already have a type guard for checking a single value, but having a solution that would do ...
2
votes
1
answer
350
views
Observable and how to control results pace
I am looking for an operator that would help me pace the results emitted from an observable, it would look like this :
[--A-BC--D-E----------------]
[--A----B----C----D----E----]
I tried AuditTime() ...
2
votes
1
answer
2k
views
How can I give an RxJS observable pipe access to the original observable's emission AND the pipe's previous emission?
I have an RxJS Observable that emits a series of changes to an underlying data structure—specifically, snapshotChanges() from an AngularFirestoreCollection.
I'm currently mapping this to an array of ...
1
vote
1
answer
307
views
How to synchronise rxjs observables
I'm looking for a way to make streams that are combined
Note: this is the simplest form of my problem, in reality I'm combining 8 different streams some are intertwined, some are async etc :(
import { ...
1
vote
1
answer
455
views
swap element in an observable array
I am trying to swap two items in the observable array. I know how to do it in the normal array. I tried the same way but it doesn't change the value.
My Stackblitz code
Here is what I tried,
...
0
votes
0
answers
67
views
`_http.get().pipe(publishReplay(), refCount())` behavior differs - if returned from a getterMethod() and - if declared as a property$
I created a mini app which shows the Continent & the Country selections
You can checkout to ng-conf/learn-rxjs-01 branch on
https://stackblitz.com/edit/stackblitz-starters-hvcdxw to view the app
...