datetime and commonEvent problem

Signed-off-by: zhuchengfeng <940848916@qq.com>
This commit is contained in:
zhuchengfeng 2022-04-14 10:00:17 +08:00
parent ec8944a7b3
commit e4ff5dbf8a
2 changed files with 6 additions and 5 deletions

View File

@ -49,14 +49,14 @@ export default class DateTimeViewModel {
this.setDateTime.bind(this)()
commonEvent.createSubscriber(mCommonEventSubscribeInfo, this.createSubscriberCallBack.bind(this));
this.unSubscriber = EventManager.subscribe(TIME_CHANGE_EVENT, (args: TimeEventArgs) => {
this.setDateTime(args.date)
this.setDateTime()
});
Log.showInfo(TAG, 'ViewModelInit end');
}
private setDateTime(date?: Date) {
private setDateTime() {
Log.showInfo(TAG, `setDateTime`)
this.timeVal = sTimeManager.formatTime(date ?? new Date())
this.timeVal = sTimeManager.formatTime(new Date())
this.dateVal = DateTimeCommon.getSystemDate()
this.weekVal = DateTimeCommon.getSystemWeek()
}

View File

@ -312,9 +312,10 @@ export class ScreenLockService {
})
}
private publish(eventName:string) {
private publish(eventName: string) {
Log.showInfo(TAG, `publish event name: ${eventName}`)
commonEvent.publish(eventName, (error, value) => {
if (error != null) {
if (error.code) {
Log.showError(TAG, 'Operation failed. Cause: ' + JSON.stringify(error));
} else {
Log.showInfo(TAG, 'publish common event success. ' + JSON.stringify(value));