packageDocumentation module import { BeEvent } from "./BeEvent" ; public export class ObservableSet < T > extends Set < T > { /** Emitted after `item` is added to this set. */ public readonly onAdded = new BeEvent < ( item : T ) => void > ( ) ; /** Emitted after `item` is deleted from this set. */ public readonly onDeleted = new BeEvent < ( item : T ) => void > ( ) ; /** Emitted after this set's contents are cleared. */ public readonly onCleared = new BeEvent < ( ) => void > ( ) ; param elements public constructor ( elements ? ) { super ( elements ) ; this . add = ( item ) => { const prevSize = this . size ; const ret = super . add ( item ) ; if ( this . size !== prevSize ) this . onAdded . raiseEvent ( item ) ; return ret ; } ; } internal public override delete ( item ) { const ret = super . delete ( item ) ; if ( ret ) this . onDeleted . raiseEvent ( item ) ; return ret ; } internal public override clear ( ) { if ( 0 !== this . size ) { super . clear ( ) ; this . onCleared . raiseEvent ( ) ; } } }