internal: incomplete vault systems behind feature flag (#2340)

This commit is contained in:
Mo
2023-06-30 09:01:56 -05:00
committed by GitHub
parent d16e401bb9
commit b032eb9c9b
638 changed files with 20321 additions and 4813 deletions

View File

@@ -0,0 +1,52 @@
import { AbstractService, InternalEventBusInterface, ApplicationEvent } from '@standardnotes/services'
import { AbstractUIServiceInterface } from './AbstractUIServiceInterface'
import { WebApplicationInterface } from '../WebApplication/WebApplicationInterface'
export class AbstractUIServicee<EventName = string, EventData = unknown>
extends AbstractService<EventName, EventData>
implements AbstractUIServiceInterface<EventName, EventData>
{
private unsubApp!: () => void
constructor(
protected application: WebApplicationInterface,
protected override internalEventBus: InternalEventBusInterface,
) {
super(internalEventBus)
this.addAppEventObserverAfterSubclassesFinishConstructing()
}
async onAppStart() {
return
}
async onAppEvent(_event: ApplicationEvent) {
return
}
private addAppEventObserverAfterSubclassesFinishConstructing() {
setTimeout(() => {
this.addAppEventObserver()
}, 0)
}
private addAppEventObserver() {
if (this.application.isStarted()) {
void this.onAppStart()
}
this.unsubApp = this.application.addEventObserver(async (event: ApplicationEvent) => {
await this.onAppEvent(event)
if (event === ApplicationEvent.Started) {
void this.onAppStart()
}
})
}
override deinit() {
;(this.application as unknown) = undefined
this.unsubApp()
;(this.unsubApp as unknown) = undefined
super.deinit()
}
}

View File

@@ -0,0 +1,7 @@
import { ApplicationEvent, ServiceInterface } from '@standardnotes/services'
export interface AbstractUIServiceInterface<EventName = string, EventData = unknown>
extends ServiceInterface<EventName, EventData> {
onAppStart(): Promise<void>
onAppEvent(event: ApplicationEvent): Promise<void>
}