diff --git a/src/ts/@overflow/commons/application/application.ts b/src/ts/@overflow/commons/application/application.ts index 61da82b..3c0bdca 100644 --- a/src/ts/@overflow/commons/application/application.ts +++ b/src/ts/@overflow/commons/application/application.ts @@ -1,52 +1,109 @@ import { Class, + Method, } from '@overflow/commons/core/reflect'; import { ClassType } from '@overflow/commons/core/type'; import { ApplicationContext } from './context'; import { - InjectableClass, - InjectableFactory, - InjectableValue, + ConfigurationAnnotation, + InstanceAnnotation, + RunnerAnnotation, WebApplicationAnnotation, } from './decorators'; +import { InstanceDefinition } from '@overflow/commons/di/factory'; export class Application { - private primaryClass: ClassType; - private applicationContext: ApplicationContext; + private _primaryClass: ClassType; + private _applicationContext: ApplicationContext; - public static run(primaryClass: ClassType): void { + public static async run(primaryClass: ClassType): Promise { let app: Application = new Application(primaryClass); + return app.run(); } public constructor(primaryClass: ClassType) { - this.primaryClass = primaryClass; + this._primaryClass = primaryClass; this.createContext(); } - private createContext(): void { - let clazz: Class = Class.forClass(this.primaryClass); + /** + * run + */ + public async run(): Promise { + let runner = this.findRunner(); + if (null === runner) { + throw new Error(`There is not exist @Runner on Application[${this._primaryClass.name}]`); + } + let instanceFactory = this._applicationContext.instanceFactory; + let instance = instanceFactory.getInstance(null, this._primaryClass); + + await runner.invoke(instance); + + return this._applicationContext; + } + + private findRunner(): Method { + let clazz: Class = Class.forClass(this._primaryClass); + let methods = clazz.getMethods(); + for (let i = 0; i < methods.length; i++) { + const method = methods[i]; + let runnerAnnotation = method.getOwnAnnotation(RunnerAnnotation); + if (undefined === runnerAnnotation) { + continue; + } + return method; + } + return null; + } + + private createContext(): ApplicationContext { + let clazz: Class = Class.forClass(this._primaryClass); let wa: WebApplicationAnnotation = clazz.getOwnAnnotation(WebApplicationAnnotation); if (undefined === wa) { - console.warn(`Class is not WebApplication type. add @WebApplication annotation to class[${this.primaryClass.name}]`); - return; + throw new Error(`Class is not WebApplication type. add @WebApplication annotation to class[${this._primaryClass.name}]`); } - let context: ApplicationContext = new ApplicationContext(); - // context.registerInjectables(wa.attributes.injectables); + this._applicationContext = new ApplicationContext(wa.attributes.injectables); - wa.attributes.injectables.forEach(injectable => { - if (undefined !== (injectable).injectableType) { - context.registerInjectable() - } else if (undefined !== (injectable).injectableFactory) { - console.log(`InjectableFactory`); - } else if (undefined !== (injectable).injectableValue) { - console.log(`InjectableValue`); - } else if (typeof injectable === 'function') { - console.log(`Class`); + this.registerJSONSources(wa.attributes.jsonSources); + this.registerConfigurations(wa.attributes.configurations); + + return this._applicationContext; + } + + private registerJSONSources(jsonSources: any[]): void { + if (undefined === jsonSources || null === jsonSources) { + return; + } + let instanceFactory = this._applicationContext.instanceFactory; + let jsons = Object.assign({}, ...jsonSources); + instanceFactory.registerJSON(jsons); + } + + private registerConfigurations(configurationTypes: ClassType[]): void { + if (undefined === configurationTypes || null === configurationTypes) { + return; + } + let instanceFactory = this._applicationContext.instanceFactory; + + configurationTypes.forEach(configurationType => { + let clazz: Class = Class.forClass(configurationType); + let configAnnotation: ConfigurationAnnotation = clazz.getOwnAnnotation(ConfigurationAnnotation); + if (undefined === configAnnotation) { + throw new Error(`Class is not Configuration type. add @Configuration annotation to class[${configurationType.name}]`); } + let instance = instanceFactory.getInstance(null, configurationType); + clazz.getMethods().forEach(method => { + let instanceAnnotation = method.getOwnAnnotation(InstanceAnnotation); + if (undefined === instanceAnnotation) { + return; + } + let singletonName = null === instanceAnnotation.attributes.name ? method.getName() : instanceAnnotation.attributes.name; + let result = method.invoke(instance); + instanceFactory.registerSingleton(singletonName, method.getReturnType(), result); + }); }); - } } diff --git a/src/ts/@overflow/commons/application/context/application_context.ts b/src/ts/@overflow/commons/application/context/application_context.ts index f1f1f9e..bd0748b 100644 --- a/src/ts/@overflow/commons/application/context/application_context.ts +++ b/src/ts/@overflow/commons/application/context/application_context.ts @@ -1,3 +1,40 @@ +import { + ClassType, +} from '@overflow/commons/core/type'; + +import { + InstanceDefinition, + InstanceFactory, +} from '@overflow/commons/di/factory'; + export class ApplicationContext { + private _instanceFactory: InstanceFactory; + + public constructor(injectables: ClassType[]) { + this._instanceFactory = new InstanceFactory(); + this.initializeInjectables(injectables); + } + + private initializeInjectables(injectables: ClassType[]): void { + if (undefined === injectables) { + return; + } + injectables.forEach(injectable => { + let name = injectable.name; + let definition: InstanceDefinition = new InstanceDefinition(); + definition.instanceClass = injectable; + definition.name = name; + + this._instanceFactory.registerInstanceDefinition(name, definition); + }); + } + + /** + * instanceFactory + */ + public get instanceFactory(): InstanceFactory { + return this._instanceFactory; + } + } diff --git a/src/ts/@overflow/commons/application/decorators/index.ts b/src/ts/@overflow/commons/application/decorators/index.ts index 3f8cbcd..16d711d 100644 --- a/src/ts/@overflow/commons/application/decorators/index.ts +++ b/src/ts/@overflow/commons/application/decorators/index.ts @@ -1,2 +1,4 @@ export * from './configuration'; +export * from './instance'; +export * from './runner'; export * from './web_application'; diff --git a/src/ts/@overflow/commons/application/decorators/instance.ts b/src/ts/@overflow/commons/application/decorators/instance.ts new file mode 100644 index 0000000..07eabf2 --- /dev/null +++ b/src/ts/@overflow/commons/application/decorators/instance.ts @@ -0,0 +1,47 @@ +import { + Annotation, + Decorator, +} from '@overflow/commons/core/reflect'; + +import { + PropertyKeyType, + TypeUtil, +} from '@overflow/commons/core/type'; + +import { + InstanceNameType, +} from '@overflow/commons/di/type'; + +export interface InstanceAnnotationAttributes { + name?: InstanceNameType; +} + +export class InstanceAnnotation implements Annotation { + public readonly attributes: InstanceAnnotationAttributes; + + public constructor(name: InstanceNameType | InstanceNameType[] | InstanceAnnotationAttributes) { + + if (undefined === name) { + this.attributes = { + name: null, + }; + return; + } + + if (TypeUtil.isString(name)) { + this.attributes = { + name: name, + }; + } else { + this.attributes = name; + } + } + + public methodDecorator(target: Object, propertyKey: PropertyKeyType, + descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void { + console.log('Instance'); + } + +} + +export const Instance = Decorator.create(InstanceAnnotation); diff --git a/src/ts/@overflow/commons/application/decorators/runner.ts b/src/ts/@overflow/commons/application/decorators/runner.ts new file mode 100644 index 0000000..162b469 --- /dev/null +++ b/src/ts/@overflow/commons/application/decorators/runner.ts @@ -0,0 +1,19 @@ +import { + Annotation, + Decorator, +} from '@overflow/commons/core/reflect'; + +import { + PropertyKeyType, +} from '@overflow/commons/core/type'; + +export class RunnerAnnotation implements Annotation { + + public methodDecorator(target: Object, propertyKey: PropertyKeyType, + descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void { + console.log('Runner'); + } + +} + +export const Runner = Decorator.create(RunnerAnnotation); diff --git a/src/ts/@overflow/commons/application/decorators/web_application.ts b/src/ts/@overflow/commons/application/decorators/web_application.ts index df33150..28fa4d3 100644 --- a/src/ts/@overflow/commons/application/decorators/web_application.ts +++ b/src/ts/@overflow/commons/application/decorators/web_application.ts @@ -8,25 +8,9 @@ import { PropertyKeyType, } from '@overflow/commons/core/type'; -export interface InjectableClass { - injectType: ClassType; - injectableType: ClassType; -} - -export interface InjectableFactory { - injectType: ClassType; - injectableFactory: (...params: any[]) => any; -} - -export interface InjectableValue { - injectName: PropertyKeyType; - injectableValue: any; -} - -export type InjectablesType = (ClassType | InjectableClass | InjectableFactory | InjectableValue)[]; - export interface WebApplicationAnnotationAttributes { - injectables?: InjectablesType; + jsonSources?: any[]; + injectables?: ClassType[]; configurations?: ClassType[]; } diff --git a/src/ts/@overflow/commons/application/type/index.ts b/src/ts/@overflow/commons/application/type/index.ts new file mode 100644 index 0000000..b38ebc9 --- /dev/null +++ b/src/ts/@overflow/commons/application/type/index.ts @@ -0,0 +1 @@ +export * from './type'; diff --git a/src/ts/@overflow/commons/application/type/type.ts b/src/ts/@overflow/commons/application/type/type.ts new file mode 100644 index 0000000..dd0a672 --- /dev/null +++ b/src/ts/@overflow/commons/application/type/type.ts @@ -0,0 +1,22 @@ +// import { +// ClassType, +// } from '@overflow/commons/core/type'; + +// import { InstanceNameType } from '@overflow/commons/di/type'; + +// export interface InjectableClass { +// injectType: ClassType; +// injectableType: ClassType; +// } + +// export interface InjectableFactory { +// injectType: ClassType; +// injectableFactory: (...params: any[]) => any; +// } + +// export interface InjectableValue { +// injectName: InstanceNameType; +// injectableValue: any; +// } + +// export type InjectablesType = ClassType | InjectableClass | InjectableFactory | InjectableValue; diff --git a/src/ts/@overflow/commons/di/decorators/index.ts b/src/ts/@overflow/commons/di/decorators/index.ts index 122f27a..628fa95 100644 --- a/src/ts/@overflow/commons/di/decorators/index.ts +++ b/src/ts/@overflow/commons/di/decorators/index.ts @@ -1,3 +1,6 @@ export * from './inject'; export * from './injectable'; +export * from './post_construct'; +export * from './pre_destroy'; export * from './resource'; +export * from './value'; diff --git a/src/ts/@overflow/commons/di/decorators/inject.ts b/src/ts/@overflow/commons/di/decorators/inject.ts index 9265121..f86158b 100644 --- a/src/ts/@overflow/commons/di/decorators/inject.ts +++ b/src/ts/@overflow/commons/di/decorators/inject.ts @@ -8,15 +8,18 @@ import { TypeUtil, } from '@overflow/commons/core/type'; +import { + InstanceNameType, +} from '@overflow/commons/di/type'; export interface InjectAnnotationAttributes { - name?: string[]; + name?: InstanceNameType[]; } export class InjectAnnotation implements Annotation { public readonly attributes: InjectAnnotationAttributes; - public constructor(name: string | string[] | InjectAnnotationAttributes) { + public constructor(name: InstanceNameType | InstanceNameType[] | InjectAnnotationAttributes) { if (undefined === name) { this.attributes = { @@ -26,11 +29,11 @@ export class InjectAnnotation implements Annotation { if (TypeUtil.isString(name)) { this.attributes = { - name: [name], + name: [name], }; } else if (TypeUtil.isArray(name)) { this.attributes = { - name: name, + name: name, }; } else { this.attributes = name; diff --git a/src/ts/@overflow/commons/di/decorators/injectable.ts b/src/ts/@overflow/commons/di/decorators/injectable.ts index a9ff182..77e126d 100644 --- a/src/ts/@overflow/commons/di/decorators/injectable.ts +++ b/src/ts/@overflow/commons/di/decorators/injectable.ts @@ -8,14 +8,18 @@ import { TypeUtil, } from '@overflow/commons/core/type'; +import { + InstanceNameType, +} from '@overflow/commons/di/type'; + export interface InjectableAnnotationAttributes { - name?: string[]; + name?: InstanceNameType[]; } export class InjectableAnnotation implements Annotation { public readonly attributes: InjectableAnnotationAttributes; - public constructor(name: string | string[] | InjectableAnnotationAttributes) { + public constructor(name: InstanceNameType | InstanceNameType[] | InjectableAnnotationAttributes) { if (undefined === name) { this.attributes = { @@ -25,7 +29,7 @@ export class InjectableAnnotation implements Annotation { if (TypeUtil.isString(name)) { this.attributes = { - name: [name], + name: [name], }; } else { this.attributes = name; diff --git a/src/ts/@overflow/commons/di/decorators/post_construct.ts b/src/ts/@overflow/commons/di/decorators/post_construct.ts new file mode 100644 index 0000000..c2185dc --- /dev/null +++ b/src/ts/@overflow/commons/di/decorators/post_construct.ts @@ -0,0 +1,42 @@ +import { + Annotation, + Decorator, +} from '@overflow/commons/core/reflect'; + +import { + PropertyKeyType, + TypeUtil, +} from '@overflow/commons/core/type'; + +export interface PostConstructAnnotationAttributes { + name?: string[]; +} + +export class PostConstructAnnotation implements Annotation { + public readonly attributes: PostConstructAnnotationAttributes; + + public constructor(name: string | string[] | PostConstructAnnotationAttributes) { + + if (undefined === name) { + this.attributes = { + }; + return; + } + + if (TypeUtil.isString(name)) { + this.attributes = { + name: [name], + }; + } else { + this.attributes = name; + } + } + + public methodDecorator(target: Object, propertyKey: PropertyKeyType, + descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void { + console.log('PostConstruct'); + } + +} + +export const PostConstruct = Decorator.create(PostConstructAnnotation); diff --git a/src/ts/@overflow/commons/di/decorators/pre_destroy.ts b/src/ts/@overflow/commons/di/decorators/pre_destroy.ts new file mode 100644 index 0000000..87b0199 --- /dev/null +++ b/src/ts/@overflow/commons/di/decorators/pre_destroy.ts @@ -0,0 +1,42 @@ +import { + Annotation, + Decorator, +} from '@overflow/commons/core/reflect'; + +import { + PropertyKeyType, + TypeUtil, +} from '@overflow/commons/core/type'; + +export interface PreDestroyAnnotationAttributes { + name?: string[]; +} + +export class PreDestroyAnnotation implements Annotation { + public readonly attributes: PreDestroyAnnotationAttributes; + + public constructor(name: string | string[] | PreDestroyAnnotationAttributes) { + + if (undefined === name) { + this.attributes = { + }; + return; + } + + if (TypeUtil.isString(name)) { + this.attributes = { + name: [name], + }; + } else { + this.attributes = name; + } + } + + public methodDecorator(target: Object, propertyKey: PropertyKeyType, + descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void { + console.log('PreDestroy'); + } + +} + +export const PreDestroy = Decorator.create(PreDestroyAnnotation); diff --git a/src/ts/@overflow/commons/di/decorators/resource.ts b/src/ts/@overflow/commons/di/decorators/resource.ts index f91f988..befbab1 100644 --- a/src/ts/@overflow/commons/di/decorators/resource.ts +++ b/src/ts/@overflow/commons/di/decorators/resource.ts @@ -8,14 +8,18 @@ import { TypeUtil, } from '@overflow/commons/core/type'; +import { + InstanceNameType, +} from '@overflow/commons/di/type'; + export interface ResourceAnnotationAttributes { - name: string[]; + name: InstanceNameType[]; } export class ResourceAnnotation implements Annotation { public readonly attributes: ResourceAnnotationAttributes; - public constructor(name: string | ResourceAnnotationAttributes) { + public constructor(name: InstanceNameType | ResourceAnnotationAttributes) { if (undefined === name) { throw new Error(`name attribute must be specified.`); @@ -23,7 +27,7 @@ export class ResourceAnnotation implements Annotation { if (TypeUtil.isString(name)) { this.attributes = { - name: [name], + name: [name], }; } else { this.attributes = name; diff --git a/src/ts/@overflow/commons/di/decorators/value.ts b/src/ts/@overflow/commons/di/decorators/value.ts new file mode 100644 index 0000000..16c83f3 --- /dev/null +++ b/src/ts/@overflow/commons/di/decorators/value.ts @@ -0,0 +1,42 @@ +import { + Annotation, + Decorator, +} from '@overflow/commons/core/reflect'; + +import { + PropertyKeyType, + TypeUtil, +} from '@overflow/commons/core/type'; + +export interface ValueAnnotationAttributes { + value: string; +} + +export class ValueAnnotation implements Annotation { + public readonly attributes: ValueAnnotationAttributes; + + public constructor(value: string | ValueAnnotationAttributes) { + + if (undefined === value) { + throw new Error(`value attribute must be specified.`); + } + + if (TypeUtil.isString(value)) { + this.attributes = { + value: value, + }; + } else { + this.attributes = value; + } + } + + public propertyDecorator?(target: Object, propertyKey: PropertyKeyType): void { + console.log('Value'); + } + + public parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void { + console.log('Value'); + } +} + +export const Value = Decorator.create(ValueAnnotation); diff --git a/src/ts/@overflow/commons/di/factory/index.ts b/src/ts/@overflow/commons/di/factory/index.ts new file mode 100644 index 0000000..a90a909 --- /dev/null +++ b/src/ts/@overflow/commons/di/factory/index.ts @@ -0,0 +1,3 @@ +export * from './instance_definition_registry'; +export * from './instance_definition'; +export * from './instance_factory'; diff --git a/src/ts/@overflow/commons/di/factory/instance_definition.ts b/src/ts/@overflow/commons/di/factory/instance_definition.ts index ceea777..9a91fca 100644 --- a/src/ts/@overflow/commons/di/factory/instance_definition.ts +++ b/src/ts/@overflow/commons/di/factory/instance_definition.ts @@ -2,13 +2,26 @@ import { ClassType, } from '@overflow/commons/core/type'; +import { + InstanceNameType, +} from '@overflow/commons/di/type'; + export class InstanceDefinition { private _instanceClass: ClassType; + private _name: InstanceNameType; - public get InstanceClass(): ClassType { + public get instanceClass(): ClassType { return this._instanceClass; } - public set InstanceClass(instanceClass: ClassType) { + public set instanceClass(instanceClass: ClassType) { this._instanceClass = instanceClass; } -} \ No newline at end of file + + public get name(): InstanceNameType { + return this._name; + } + public set name(name: InstanceNameType) { + this._name = name; + } + +} diff --git a/src/ts/@overflow/commons/di/factory/instance_definition_registry.ts b/src/ts/@overflow/commons/di/factory/instance_definition_registry.ts new file mode 100644 index 0000000..e275739 --- /dev/null +++ b/src/ts/@overflow/commons/di/factory/instance_definition_registry.ts @@ -0,0 +1,15 @@ +import { + InstanceNameType, +} from '@overflow/commons/di/type'; + +import {InstanceDefinition} from './instance_definition'; + +export interface InstanceDefinitionRegistry { + registerInstanceDefinition(name: InstanceNameType, instanceDefinition:InstanceDefinition): void; + removeInstanceDefinition(name: InstanceNameType): void; + getInstanceDefinition(name: InstanceNameType): InstanceDefinition; + containsInstanceDefinition(name: InstanceNameType): boolean; + getInstanceDefinitionNames(): InstanceNameType[]; + getInstanceDefinitionCount(): number; + isInstanceNameInUse(name: InstanceNameType): boolean; +} diff --git a/src/ts/@overflow/commons/di/factory/instance_factory.ts b/src/ts/@overflow/commons/di/factory/instance_factory.ts new file mode 100644 index 0000000..f81869e --- /dev/null +++ b/src/ts/@overflow/commons/di/factory/instance_factory.ts @@ -0,0 +1,65 @@ +import { + ClassType, +} from '@overflow/commons/core/type'; + +import { + InstanceNameType, +} from '@overflow/commons/di/type'; + +import {InstanceDefinitionRegistry} from './instance_definition_registry'; +import {InstanceDefinition} from './instance_definition'; + +export class InstanceFactory implements InstanceDefinitionRegistry { + + + /** + * getInstance + */ + public getInstance(name: InstanceNameType, requiredType: ClassType, ...args: any[]): any { + return null; + } + + /** + * containsInstance + */ + public containsInstance(name: InstanceNameType): boolean { + return false; + } + + public registerJSON(json: any): void { + // + } + + public registerSingleton(name: InstanceNameType, instanceType: any, instance: any): void { + // + } + + public registerInstanceDefinition(name: InstanceNameType, instanceDefinition: InstanceDefinition): void { + // + } + + public removeInstanceDefinition(name: InstanceNameType): void { + // + } + + public getInstanceDefinition(name: InstanceNameType): InstanceDefinition { + // + } + + public containsInstanceDefinition(name: InstanceNameType): boolean { + // + } + + public getInstanceDefinitionNames(): InstanceNameType[] { + // + } + + public getInstanceDefinitionCount(): number { + // + } + + public isInstanceNameInUse(name: InstanceNameType): boolean { + // + } + +} diff --git a/src/ts/@overflow/commons/di/factory/property_value.ts b/src/ts/@overflow/commons/di/factory/property_value.ts index 7c570eb..90128de 100644 --- a/src/ts/@overflow/commons/di/factory/property_value.ts +++ b/src/ts/@overflow/commons/di/factory/property_value.ts @@ -1,18 +1,18 @@ import { PropertyKeyType } from '@overflow/commons/core/type'; export class PropertyValue { - private readonly name: PropertyKeyType; - private readonly value: any; + private readonly _name: PropertyKeyType; + private readonly _value: any; public constructor(name: PropertyKeyType, value: any) { - this.name = name; - this.value = value; + this._name = name; + this._value = value; } - public get Name(): PropertyKeyType { - return this.name; + public get name(): PropertyKeyType { + return this._name; } - public get Value(): any { - return this.value; + public get value(): any { + return this._value; } -} \ No newline at end of file +} diff --git a/src/ts/@overflow/commons/di/type/index.ts b/src/ts/@overflow/commons/di/type/index.ts new file mode 100644 index 0000000..b38ebc9 --- /dev/null +++ b/src/ts/@overflow/commons/di/type/index.ts @@ -0,0 +1 @@ +export * from './type'; diff --git a/src/ts/@overflow/commons/di/type/type.ts b/src/ts/@overflow/commons/di/type/type.ts new file mode 100644 index 0000000..d884b32 --- /dev/null +++ b/src/ts/@overflow/commons/di/type/type.ts @@ -0,0 +1,5 @@ +import { + IdentityType, +} from '@overflow/commons/core/type'; + +export type InstanceNameType = IdentityType; diff --git a/src/ts/@overflow/webapp/config/injectables.ts b/src/ts/@overflow/webapp/config/injectables.ts index 3b0e1a7..9b08b07 100644 --- a/src/ts/@overflow/webapp/config/injectables.ts +++ b/src/ts/@overflow/webapp/config/injectables.ts @@ -1,22 +1,10 @@ -import { InjectablesType } from '@overflow/commons/application/decorators'; +import { + ClassType, +} from '@overflow/commons/core/type'; + import { WebAppDispatcherReducer } from '../redux'; - -export const injectables: InjectablesType = [ +export const injectables: ClassType[] = [ WebAppDispatcherReducer, - { - injectType: WebAppDispatcherReducer, - injectableType: WebAppDispatcherReducer, - }, - { - injectType: WebAppDispatcherReducer, - injectableFactory: function(): any { - return new WebAppDispatcherReducer(); - }, - }, - { - injectName: 'Name', - injectableValue: 'TestValue', - }, ]; diff --git a/src/ts/@overflow/webapp/config/reducer_configuration.ts b/src/ts/@overflow/webapp/config/reducer_configuration.ts index ce01e39..ba6e1d7 100644 --- a/src/ts/@overflow/webapp/config/reducer_configuration.ts +++ b/src/ts/@overflow/webapp/config/reducer_configuration.ts @@ -4,17 +4,13 @@ import { import { Configuration, + Instance, } from '@overflow/commons/application/decorators'; -import { - Injectable, -} from '@overflow/commons/di/decorators'; - - @Configuration() export class ReducerConfiguration { - @Injectable() + @Instance() public store(): Store { return null; } diff --git a/src/ts/@overflow/webapp/config/webapp_configuration.ts b/src/ts/@overflow/webapp/config/webapp_configuration.ts index c8b725f..0d5aba5 100644 --- a/src/ts/@overflow/webapp/config/webapp_configuration.ts +++ b/src/ts/@overflow/webapp/config/webapp_configuration.ts @@ -1,7 +1,15 @@ -import { Configuration } from '@overflow/commons/application/decorators'; - +import { + Configuration, + Instance, +} from '@overflow/commons/application/decorators'; @Configuration() export class WebAppConfiguration { - + /** + * container + */ + @Instance() + public container(): HTMLElement { + return null; + } } diff --git a/src/ts/@overflow/webapp/index.tsx b/src/ts/@overflow/webapp/index.tsx index 8418b79..2d3e6eb 100644 --- a/src/ts/@overflow/webapp/index.tsx +++ b/src/ts/@overflow/webapp/index.tsx @@ -29,8 +29,14 @@ import { } from 'react-hot-loader'; import { Application } from '@overflow/commons/application'; -import { WebApplication } from '@overflow/commons/application/decorators'; -import { Inject } from '@overflow/commons/di/decorators'; +import { + Runner, + WebApplication, +} from '@overflow/commons/application/decorators'; +import { + Inject, + Resource, +} from '@overflow/commons/di/decorators'; import config, { injectables, @@ -65,7 +71,10 @@ class WebAppApplication { private static isProduction:boolean = process.env.NODE_ENV === 'production' ? true : false; private static useReduxDevTools:boolean = window.devToolsExtension && !WebAppApplication.isProduction ? true : false; + @Resource() private container: HTMLElement; + + @Inject() private store: Store; private history: History; @@ -77,6 +86,7 @@ class WebAppApplication { this.history = createHashHistory(); } + @Runner() public async run(): Promise { try { this.renderLoading();