Skip to content

Commit

Permalink
fix(groupBy): durationSelector cannot keep source alive
Browse files Browse the repository at this point in the history
Fix test case "Observable.prototype.groupBy() should return inner that does not throw when faulty outer is
unsubscribed early". The Observable given as argument to the
durationSelector of groupBy should not participate in the refCounting of
the outer Observable.
  • Loading branch information
Andre Medeiros authored and benlesh committed Oct 13, 2015
1 parent 45b8ebd commit 57e4207
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/operators/groupBy-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export class RefCountSubscription<T> extends Subscription<T> {
export class GroupedObservable<T> extends Observable<T> {
constructor(public key: string,
private groupSubject: Subject<T>,
private refCountSubscription: RefCountSubscription<T>) {
private refCountSubscription?: RefCountSubscription<T>) {
super();
}

_subscribe(subscriber: Subscriber<T>) {
const subscription = new Subscription();
if (!this.refCountSubscription.isUnsubscribed) {
if (this.refCountSubscription && !this.refCountSubscription.isUnsubscribed) {
subscription.add(new InnerRefCountSubscription(this.refCountSubscription));
}
subscription.add(this.groupSubject.subscribe(subscriber));
Expand Down
2 changes: 1 addition & 1 deletion src/operators/groupBy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class GroupBySubscriber<T, R> extends Subscriber<T> {
let groupedObservable = new GroupedObservable<R>(key, group, this.refCountSubscription);

if (durationSelector) {
let duration = tryCatch(durationSelector)(groupedObservable);
let duration = tryCatch(durationSelector)(new GroupedObservable<R>(key, group));
if (duration === errorObject) {
this.error(duration.e);
} else {
Expand Down

0 comments on commit 57e4207

Please sign in to comment.