export interface IPageTitleChangeHandler { onPageTitleChange ( title ) : void ; } class PageTitleService { private handlers : IPageTitleChangeHandler [ ] = [ ] ; constructor ( private readonly window ) { } public setPageTitle = ( title ) : void => { this . window . document . title = title ; this . handlers . forEach ( ( handler ) => { handler . onPageTitleChange ( title ) ; } ) ; } ; public registerPageTitleChangeHandler = ( handler ) => { this . handlers . push ( handler ) ; } ; public deregisterPageTitleChangeHandler = ( handler ) => { const index = this . handlers . indexOf ( handler , 0 ) ; if ( index > - 1 ) { this . handlers . splice ( index , 1 ) ; } } ; } export default PageTitleService ;