import { IEventDispatcher } from "../../events/api/IEventDispatcher" ; import { PinEvent } from "../api/PinEvent" ; private export class Pin { private _instances : Map < any , boolean > = new Map < any , boolean > ( ) ; private _dispatcher : IEventDispatcher ; private constructor ( dispatcher ) { this . _dispatcher = dispatcher ; } param instance public detain ( instance ) { if ( ! this . _instances . get ( instance ) ) { this . _instances . set ( instance , true ) ; this . _dispatcher . dispatchEvent ( new PinEvent ( PinEvent . DETAIN , instance ) ) ; } } param instance public release ( instance ) { if ( this . _instances . get ( instance ) ) { this . _instances . delete ( instance ) ; this . _dispatcher . dispatchEvent ( new PinEvent ( PinEvent . RELEASE , instance ) ) ; } } /**
     * Removes all pins
     */ public releaseAll ( ) { this . _instances . forEach ( ( value , key ) => this . release ( key ) ) ; } }