feat(core): 新增store

This commit is contained in:
roymondchen 2022-08-08 17:18:45 +08:00 committed by jia000
parent eba6cbccde
commit 5f78bbd7b7
2 changed files with 13 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import type { EventItemConfig, MComponent, MContainer, MPage } from '@tmagic/sch
import type App from './App';
import type Page from './Page';
import Store from './Store';
interface NodeOptions {
config: MComponent | MContainer;
@ -39,6 +40,7 @@ class Node extends EventEmitter {
public page?: Page;
public parent?: Node;
public app: App;
public store = new Store();
constructor(options: NodeOptions) {
super();

View File

@ -0,0 +1,11 @@
export default class Store {
private data: Record<string, any> = {};
public set(key: string, value: any) {
this.data[key] = value;
}
public get(key: string) {
return this.data[key];
}
}