plane/apps/space/store/user.ts
guru_sainath cd5e5b96da
feat: Mobx integration, List and Kanban boards implementation in plane space (#1844)
* feat: init mobx and issue filter

* feat: Implemented list and kanban views in plane space and integrated mobx.

* feat: updated store type check
2023-08-11 17:18:33 +05:30

44 lines
936 B
TypeScript

// mobx
import { observable, action, computed, makeObservable, runInAction } from "mobx";
// service
import UserService from "services/user.service";
// types
import { IUserStore } from "./types";
class UserStore implements IUserStore {
currentUser: any | null = null;
// root store
rootStore;
// service
userService;
constructor(_rootStore: any) {
makeObservable(this, {
// observable
currentUser: observable,
// actions
// computed
});
this.rootStore = _rootStore;
this.userService = new UserService();
}
getUserAsync = async () => {
try {
const response = this.userService.currentUser();
if (response) {
runInAction(() => {
this.currentUser = response;
});
}
} catch (error) {
console.error("error", error);
runInAction(() => {
// render error actions
});
}
};
}
export default UserStore;