plane/web/store/modules.ts

56 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-09-20 06:52:48 +00:00
import { action, computed, observable, makeObservable, runInAction } from "mobx";
// types
import { RootStore } from "./root";
// services
2023-09-21 09:30:19 +00:00
import { ProjectService } from "services/project.service";
import { IssueService } from "services/issue.service";
2023-09-20 06:52:48 +00:00
export interface IModuleStore {
loader: boolean;
error: any | null;
moduleId: string | null;
setModuleId: (moduleSlug: string) => void;
}
class ModuleStore implements IModuleStore {
loader: boolean = false;
error: any | null = null;
moduleId: string | null = null;
// root store
rootStore;
// services
projectService;
issueService;
constructor(_rootStore: RootStore) {
makeObservable(this, {
loader: observable,
error: observable.ref,
moduleId: observable.ref,
// computed
// actions
setModuleId: action,
});
this.rootStore = _rootStore;
2023-09-21 09:30:19 +00:00
this.projectService = new ProjectService();
this.issueService = new IssueService();
2023-09-20 06:52:48 +00:00
}
// computed
// actions
setModuleId = (moduleSlug: string) => {
this.moduleId = moduleSlug ?? null;
};
}
export default ModuleStore;