Some operator supported a resultSelector argument that acted as mapping function on the result of that operator.
The same behavior can be reproduced with the map
operator, therefore this argument became deprecated.
This deprecation was introduced in RxJS 6.0 and will become breaking with RxJS 8.
There were two reasons for actually deprecating those parameters:
- It increases the bundle size of every operator
- In some scenarios values had to be retained in memory causing a general memory pressure
Instead of using the resultSelector
Argument, you can leverage the map
operator on the inner Observable:
import {fromEvent, interval} from 'rxjs';
import {switchMap, map} from 'rxjs/operators';
// deprecated
fromEvent(document, 'click').pipe(
switchMap(x => interval(0, 1000), (x) => x+1)
);
// suggested change
fromEvent(document, 'click').pipe(
switchMap(x => interval(0, 1000).pipe(
map(x => x+1)
))
);