import { Observable } from '../../../../esl-utils/abstract/observable' ; import type { ESLCarousel } from '../esl-carousel' ; export abstract class ESLCarouselView { protected readonly carousel : ESLCarousel ; protected constructor ( carousel ) { this . carousel = carousel ; } public abstract bind ( ) ; public abstract draw ( ) ; public abstract goTo ( nextIndex , direction ) ; public abstract unbind ( ) ; } export type ESLCarouselViewConstructor = new ( carousel ) => ESLCarouselView ; let eslRegistryInstance = null ; export class ESLCarouselViewRegistry extends Observable < ( name : string , view : ESLCarouselViewConstructor ) => void > { private registry = new Map < string , ESLCarouselViewConstructor > ( ) ; public static get instance ( ) { if ( eslRegistryInstance === null ) { eslRegistryInstance = new ESLCarouselViewRegistry ( ) ; } return eslRegistryInstance ; } public createViewInstance ( name , carousel ) { const View = this . registry . get ( name ) ; return View ? new View ( carousel ) : null ; } public registerView ( name , view ) { if ( this . registry . has ( name ) ) { throw new Error ( `View with name ${ name } already defined` ) ; } this . registry . set ( name , view ) ; this . fire ( name , view ) ; } }