Skip to content

Commit

Permalink
use switch map to implement reset
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanibus committed Jun 22, 2021
1 parent f921d57 commit e65c641
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/strategies.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { merge, of } from 'rxjs';
import {
concat,
concatMap,
switchMap,
concatMapTo,
filter,
map,
scan
scan,
} from 'rxjs/operators';

module.exports = function () {
Expand Down Expand Up @@ -113,18 +113,20 @@ module.exports = function () {
)
);
const reset$ = this.reset$;
return merge(source$.pipe(
concatMap(data =>
of(data).pipe(
concat(
events$.pipe(
scan((current, callback) => sortAndTrim(callback(current)), data))
return merge(source$, reset$.pipe(concatMapTo(source$))).pipe(
switchMap((data) =>
of(data).pipe(
concat(
events$.pipe(
scan(
(current, callback) => sortAndTrim(callback(current)),
data
)
)
),
),
),
reset$.pipe(concatMapTo(source$))
)
)
)
);
}
};
};

0 comments on commit e65c641

Please sign in to comment.