Files
CocosCreatorTutorial/MobXDemo1/assets/Script/StoreHello.ts
2019-02-03 14:59:34 +08:00

22 lines
434 B
TypeScript

import { observable, action } from "mobx";
export class StoreHello {
private static instance: StoreHello = null;
public static getInstance() {
if (this.instance == null) {
this.instance = new StoreHello();
}
return this.instance;
}
@observable
public count: number = 0;
@action
public addCount() {
this.count = this.count || 0;
this.count++;
}
}