Skip to content

Commit 23a7574

Browse files
Andre Medeirosbenlesh
authored andcommitted
fix(groupBy): fix bugs related to group resets
When using durationSelector on groupBy operator, completed group Observables were not being properly removed from the underlying Map of groups by key. This fixes the following test cases: - Observable.prototype.groupBy() should allow using a keySelector, elementSelector, and durationSelector - Observable.prototype.groupBy() should allow using a keySelector and a durationSelector, outer throws - Observable.prototype.groupBy() should allow using a durationSelector, but keySelector throws - Observable.prototype.groupBy() should allow using a durationSelector, but elementSelector throws - Observable.prototype.groupBy() should allow an inner to be unsubscribed early but other inners continue, with durationSelector - Observable.prototype.groupBy() should allow inners to be unsubscribed early at different times, with durationSelector - Observable.prototype.groupBy() should return inners that when subscribed late exhibit hot behavior
1 parent cd37418 commit 23a7574

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/operators/groupBy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class GroupBySubscriber<T, R> extends Subscriber<T> {
116116
}
117117

118118
removeGroup(key: string) {
119-
this.groups[key] = null;
119+
this.groups.delete(key);
120120
}
121121
}
122122

src/util/FastMap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class FastMap {
1919
forEach(cb, thisArg) {
2020
const values = this._values;
2121
for (let key in values) {
22-
if (values.hasOwnProperty(key)) {
22+
if (values.hasOwnProperty(key) && values[key] !== null) {
2323
cb.call(thisArg, values[key], key);
2424
}
2525
}

0 commit comments

Comments
 (0)