@@ -13,7 +13,7 @@ import {
1313 QueryList ,
1414 ViewEncapsulation
1515} from '@angular/core' ;
16- import { defer , merge , Observable , Subject } from 'rxjs' ;
16+ import { defer , merge , Observable , Subject , Subscription } from 'rxjs' ;
1717import { startWith , switchMap , take , takeUntil } from 'rxjs/operators' ;
1818
1919import { toBoolean , EventRegistry } from '@angular-mdc/web/common' ;
@@ -38,6 +38,9 @@ export class MdcChipSet implements AfterContentInit, OnInit, OnDestroy {
3838 /** Emits whenever the component is destroyed. */
3939 private _destroy = new Subject < void > ( ) ;
4040
41+ /** Subscription to remove changes in chips. */
42+ private _chipRemoveSubscription : Subscription | null ;
43+
4144 /**
4245 * Indicates that the chips in the set are choice chips, which allow a single selection from a set of options.
4346 */
@@ -81,6 +84,11 @@ export class MdcChipSet implements AfterContentInit, OnInit, OnDestroy {
8184
8285 @ContentChildren ( MdcChip ) chips : QueryList < MdcChip > ;
8386
87+ /** Combined stream of all of the child chips' remove change events. */
88+ get chipRemoveChanges ( ) : Observable < MdcChipInteractionEvent > {
89+ return merge ( ...this . chips . map ( chip => chip . removed ) ) ;
90+ }
91+
8492 /** Combined stream of all of the chip change events. */
8593 readonly chipSelectionChanges : Observable < MdcChipInteractionEvent > = defer ( ( ) => {
8694 if ( this . chips ) {
@@ -122,6 +130,10 @@ export class MdcChipSet implements AfterContentInit, OnInit, OnDestroy {
122130 this . _foundation . handleChipInteraction ( event ) ;
123131 } ) ;
124132
133+ this . _chipRemoveSubscription = this . chipRemoveChanges . subscribe ( ( event : MdcChipInteractionEvent ) => {
134+ this . _foundation . handleChipRemoval ( event ) ;
135+ } ) ;
136+
125137 this . chips . changes . pipe ( startWith ( null ) , takeUntil ( this . _destroy ) ) . subscribe ( ( ) => {
126138 Promise . resolve ( ) . then ( ( ) => {
127139 this . chips . forEach ( chip => {
0 commit comments