ya-webadb/apps/demo/state/global.ts
2022-02-18 11:36:10 +08:00

36 lines
795 B
TypeScript

import { Adb } from "@yume-chan/adb";
import { action, makeAutoObservable } from 'mobx';
export class GlobalState {
device: Adb | undefined = undefined;
errorDialogVisible = false;
errorDialogMessage = '';
logVisible = false;
constructor() {
makeAutoObservable(this, {
hideErrorDialog: action.bound,
toggleLog: action.bound,
});
}
setDevice(device: Adb | undefined) {
this.device = device;
}
showErrorDialog(message: string) {
this.errorDialogVisible = true;
this.errorDialogMessage = message;
}
hideErrorDialog() {
this.errorDialogVisible = false;
}
toggleLog() {
this.logVisible = !this.logVisible;
}
}
export const globalState = new GlobalState();