LanguageServiceNoLS.ts 514 B

1234567891011121314151617181920212223242526272829
  1. export class LanguageServiceNoLS {
  2. private listeners: Array<() => void> = [];
  3. constructor (private lang: string) { }
  4. setupListener (): void { }
  5. notifyChange (): void {
  6. this.listeners.forEach(l => l());
  7. }
  8. setLang (lang: string): void {
  9. this.lang = lang;
  10. this.notifyChange();
  11. }
  12. getLang (): string {
  13. return this.lang;
  14. }
  15. getDefaultLang (): string {
  16. return this.lang;
  17. }
  18. registerLanguageChangeListener (listener: () => void) {
  19. this.listeners.push(listener);
  20. }
  21. }