Questions tagged [rxjs-pipeable-operators]
350 questions
35
votes
3 answers
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 button multiple times, but I'd like to limit the times…

Cleave Kokle
- 373
- 1
- 3
- 5
21
votes
1 answer
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 should I use 1 pipe instead?
observable.pipe(
…

user2992476
- 1,536
- 2
- 17
- 29
16
votes
5 answers
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 results using the scan operator.
This component…

Ritchie
- 502
- 4
- 13
14
votes
3 answers
RXJS Combining multiple observables inside a pipe
I have an API call that returns a certain amount of ids.
Each of these ids are used to make a new api call. The results of these API calls need to be combined into a single object.
At first I used a loop inside the .pipe(map) operator of the first…

BartKrul
- 577
- 1
- 8
- 21
14
votes
2 answers
Rxjs `distinctUntilChanged()` appears to not be working
In an rxjs stream, I'm using distinctUntilChanged with lodash's isEqual to filter out duplicate values. However it appears to not be working as expected. Take the following code snippet
import { isEqual } from 'lodash-es';
let cachedValue:…

John
- 9,249
- 5
- 44
- 76
13
votes
7 answers
RxJS cache and refresh with shareReplay
I am using a caching for some data retrieved from an API, for logical reasons the stored data is valid only for a limited time, so I am making use of something like:
someApiData$ = this.getData()
.pipe(shareReplay(1, 3000))
What seems to be…

Ravid Goldenberg
- 2,119
- 4
- 39
- 59
13
votes
1 answer
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 deliberately)
var someResult = $observable-A; // wait to…

James
- 2,516
- 2
- 19
- 31
9
votes
5 answers
RxJS mergeMap() with original order
The abstract problem
Is there any way to consume the result of a mergeMap in the original order of the outer observable, while still allowing the inner observables to run in parallel?
More detailed explanation
Let's look at two merge-mapping…

Joseph Silber
- 214,931
- 59
- 362
- 292
9
votes
2 answers
How to call forkJoin inside a pipe?
TL;DR
Is it possible to use forkJoin inside a pipe of an observable?
Full story:
I have a service that returns Observable of array of objects. For each of those objects I will need to make another call to a service which returns an observable, and…

morynicz
- 2,322
- 2
- 20
- 34
9
votes
1 answer
How to import ErrorObservable or _throw in rxjs6? throw in rxjs
I am migrating to rxjs 6.0.0-ucandoit-rc.6. In version 5.5.2 I was using ErrorObservable to create errorous observable.
I was using the way recommended here: https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md
Because throw is a…

Martin Nuc
- 5,604
- 2
- 42
- 48
8
votes
2 answers
How can I delay an observable only if it returns faster than the delay
Take for example:
this.http.get('/getdata').pipe(delay(2000))
I would like this request to take a minimum of 2s to complete, but not any longer than it takes for the request to complete.
In other words:
if the request takes 1s to complete, I want…

parliament
- 21,544
- 38
- 148
- 238
7
votes
3 answers
angular 6 filter the async pipe results
I use angular 6 and I would like to filter the results of an async pipe, before rendering them in the UI.
Here is my code right now
this.results = this.form.get('name').valueChanges.pipe(
filter(formdata => formdata.name.length > 0),
…

slevin
- 4,166
- 20
- 69
- 129
6
votes
3 answers
Cache Http requests using only RxJS operators
I'm trying to achieve what is described here: https://www.prestonlamb.com/blog/rxjs-cache-and-refresh-in-angular
In other words, I want to cache an observable, during a given time (let's say 1minute). When a subscription is made after that given…

Sébastien BATEZAT
- 2,353
- 26
- 42
6
votes
3 answers
Confusing behavior of rxjs operator `delay`
I'm a bit confused about the rxjs operator delay.
When I test it with a fake observable created with from, then I only see an initial delay:
const { from } = Rx;
const { delay, tap } = RxOperators;
from([1, 2, 3, 4]).pipe(
tap(console.log),
…

Good Night Nerd Pride
- 8,245
- 4
- 49
- 65
6
votes
3 answers
Rxjs, Pipe with one argument
Are there any differences when using the Pipe function with one argument, versus not using Pipe at all?
I am currently implementing the takeUntil unsubscribe strategy from this article. In the "official solution" from this SO question the takeUntil…

Anders
- 403
- 3
- 17