import { makeAutoObservable } from 'mobx';
import { TabViewModel, UITabView } from './TabViewModel';

/**
 * This is the main class to handle tabs in the app.
 * An app will have many tabs
 */
export class TabsModel {
  tabViews: Record<string, TabViewModel>;
  constructor() {
    this.tabViews = {};
    makeAutoObservable(this);
  }

  get = (tabId: string): TabViewModel | undefined => {
    return this.tabViews[tabId];
  };

  createTab = (tab: UITabView) => {
    this.tabViews[tab.id] = new TabViewModel(tab);
  };
}
