import { ReSubstitute } from '@fdmg/resubstitute' ; import { Template } from '../utils/FdEvents' ; class TemplatesStore extends ReSubstitute { private templates : Template [ ] = [ ] ; addTemplate ( template ) { const templates = this . templates . concat ( template ) ; templates . sort ( ( t1 , t2 ) => t1 . name . localeCompare ( t2 . name , undefined , { numeric : true , sensitivity : 'base' , } ) ) ; this . templates = templates ; this . trigger ( ) ; } setTemplates ( templates ) { templates . sort ( ( t1 , t2 ) => t1 . name . localeCompare ( t2 . name , undefined , { numeric : true , sensitivity : 'base' , } ) ) ; this . templates = templates || [ ] ; this . trigger ( ) ; } clear ( ) { this . templates = [ ] ; this . trigger ( ) ; } getTemplates ( ) { return this . templates ; } } export = new TemplatesStore ( ) ;