import { Container , DisplayObject } from "pixi.js" ; import { IClass , EventDispatcher } from "@robotlegsjs/core" ; import { IViewHandler } from "../api/IViewHandler" ; import { ContainerBindingEvent } from "./ContainerBindingEvent" ; private export class ContainerBinding extends EventDispatcher { private _parent : ContainerBinding ; private public get parent ( ) : ContainerBinding { return this . _parent ; } private public set parent ( value ) { this . _parent = value ; } private _container : Container ; private public get container ( ) : Container { return this . _container ; } private _handlers : IViewHandler [ ] = [ ] ; private constructor ( container ) { super ( ) ; this . _container = container ; } private public addHandler ( handler ) { if ( this . _handlers . indexOf ( handler ) > - 1 ) { return ; } this . _handlers . push ( handler ) ; } private public removeHandler ( handler ) { let index = this . _handlers . indexOf ( handler ) ; if ( index > - 1 ) { this . _handlers . splice ( index , 1 ) ; if ( this . _handlers . length === 0 ) { this . dispatchEvent ( new ContainerBindingEvent ( ContainerBindingEvent . BINDING_EMPTY ) ) ; } } } private public handleView ( view , type ) { let length = this . _handlers . length ; for ( let i = 0 ; i < length ; i ++ ) { let handler = this . _handlers [ i ] ; handler . handleView ( view , type ) ; } } }