mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 18:16:15 +08:00
feat(infra): framework
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import type { Framework } from '../../framework';
|
||||
import { LifecycleService } from './service/lifecycle';
|
||||
|
||||
export {
|
||||
ApplicationFocused,
|
||||
ApplicationStarted,
|
||||
LifecycleService,
|
||||
} from './service/lifecycle';
|
||||
|
||||
export function configureLifecycleModule(framework: Framework) {
|
||||
framework.service(LifecycleService);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { createEvent, Service } from '../../../framework';
|
||||
|
||||
/**
|
||||
* Event that is emitted when application is started.
|
||||
*/
|
||||
export const ApplicationStarted = createEvent<boolean>('ApplicationStartup');
|
||||
|
||||
/**
|
||||
* Event that is emitted when browser tab or windows is focused again, after being blurred.
|
||||
* Can be used to actively refresh some data.
|
||||
*/
|
||||
export const ApplicationFocused = createEvent<boolean>('ApplicationFocused');
|
||||
|
||||
export class LifecycleService extends Service {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
applicationStart() {
|
||||
this.eventBus.emit(ApplicationStarted, true);
|
||||
}
|
||||
|
||||
applicationFocus() {
|
||||
this.eventBus.emit(ApplicationFocused, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user