Skip to content

Commit

Permalink
fix(chip-list): stateChanges stream not being completed (#8636)
Browse files Browse the repository at this point in the history
Fixes the `stateChanges` subject not being completed, potentially causing a memory leak if the subscribers forget to unsubscribe.
  • Loading branch information
crisbeto authored and tinayuangao committed Dec 1, 2017
1 parent bec4cfe commit 61dada8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/chips/chip-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,15 @@ describe('MatChipList', () => {
});
});

it('should complete the stateChanges stream on destroy', () => {
const spy = jasmine.createSpy('stateChanges complete');
const subscription = chipListInstance.stateChanges.subscribe(undefined, undefined, spy);

fixture.destroy();
expect(spy).toHaveBeenCalled();
subscription.unsubscribe();
});

});

describe('selection logic', () => {
Expand Down
1 change: 1 addition & 0 deletions src/lib/chips/chip-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
this._changeSubscription.unsubscribe();
}
this._dropSubscriptions();
this.stateChanges.complete();
}


Expand Down

0 comments on commit 61dada8

Please sign in to comment.