From 23a7574f84bdc8f107d7f7825f81ac4ba2631c61 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Mon, 12 Oct 2015 14:05:59 +0300 Subject: [PATCH] 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 --- src/operators/groupBy.ts | 2 +- src/util/FastMap.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/operators/groupBy.ts b/src/operators/groupBy.ts index bdc287dd45..0cfbea43b6 100644 --- a/src/operators/groupBy.ts +++ b/src/operators/groupBy.ts @@ -116,7 +116,7 @@ class GroupBySubscriber extends Subscriber { } removeGroup(key: string) { - this.groups[key] = null; + this.groups.delete(key); } } diff --git a/src/util/FastMap.ts b/src/util/FastMap.ts index 448944fd2b..8fbeb31cdd 100644 --- a/src/util/FastMap.ts +++ b/src/util/FastMap.ts @@ -19,7 +19,7 @@ export default class FastMap { forEach(cb, thisArg) { const values = this._values; for (let key in values) { - if (values.hasOwnProperty(key)) { + if (values.hasOwnProperty(key) && values[key] !== null) { cb.call(thisArg, values[key], key); } }