import { Directive , OnDestroy , OnInit , Optional } from '@angular/core' ; import { Subject } from 'rxjs' ; import { ConduitZone } from './conduit-zone.service' ; import { ConduitProperties } from './interfaces/conduit-properties' ; @ Directive ( { selector : 'ux-conduit' } ) export class ConduitComponent implements OnInit , OnDestroy { constructor ( @ Optional ( ) protected _zone ) { } /** We need to register the conduits with the zone when the component is initialised */ ngOnInit ( ) { this . _zone . registerConduits ( this ) ; } /** We need to unregister the conduits when the component is destroyed */ ngOnDestroy ( ) { this . _zone . unregisterConduits ( this ) ; } /** Alter the properties of a conduit dynamically */ setConduitProperties ( subject , properties ) { this . _zone . setConduitProperties ( subject , properties ) ; } /** Programmatically create a conduit at runtime */ createConduit ( subject , properties ) { this . _zone . createConduit ( subject , properties ) ; } }