namespace Leaf { export interface ApplicationLifeCircle { foregroundInitialize: () => void backgroundInitialize: () => void } export abstract class Application implements ApplicationLifeCircle { public initialize() { this.serviceContext.setup(() => { this.foregroundInitialize() }) } public implements(lifecircle: Partial) { for (let prop in lifecircle) { this[prop] = lifecircle[prop] } } foregroundInitialize: () => void = function () { } backgroundInitialize: () => void = function () { } serviceContext = new ServiceContext } }