27 lines
938 B
TypeScript
27 lines
938 B
TypeScript
import ActivityScheduleService from "./module/Config/ActivityScheduleService";
|
|
|
|
const { ccclass } = cc._decorator;
|
|
|
|
/** Shared home refresh lifecycle, independent of any particular activity entry. */
|
|
@ccclass
|
|
export default class HomeActivitySchedule extends cc.Component {
|
|
onEnable(): void {
|
|
cc.game.on(cc.game.EVENT_SHOW, this.onShow, this);
|
|
cc.game.on(cc.game.EVENT_HIDE, this.onHide, this);
|
|
this.onShow();
|
|
}
|
|
private tick = (): void => { ActivityScheduleService.tick(); };
|
|
private onShow = (): void => {
|
|
this.unschedule(this.tick);
|
|
this.schedule(this.tick, 1);
|
|
this.tick();
|
|
void ActivityScheduleService.sync(true);
|
|
};
|
|
private onHide = (): void => { this.unschedule(this.tick); };
|
|
onDisable(): void {
|
|
this.onHide();
|
|
cc.game.off(cc.game.EVENT_SHOW, this.onShow, this);
|
|
cc.game.off(cc.game.EVENT_HIDE, this.onHide, this);
|
|
}
|
|
}
|