From 57acc39ee261b1cfec8918df113a5fa788ee341d Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 29 Dec 2017 17:02:42 +0900 Subject: [PATCH] ing --- .../commons/di/factory/instance_factory.ts | 3 ++- .../webapp/config/webapp_configuration.ts | 17 +++++++++++++++-- src/ts/@overflow/webapp/index.tsx | 19 ++++--------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/ts/@overflow/commons/di/factory/instance_factory.ts b/src/ts/@overflow/commons/di/factory/instance_factory.ts index d164637..910da5c 100644 --- a/src/ts/@overflow/commons/di/factory/instance_factory.ts +++ b/src/ts/@overflow/commons/di/factory/instance_factory.ts @@ -28,7 +28,7 @@ export class InstanceFactory implements InstanceDefinitionRegistry { * getInstance */ public getInstance(name: InstanceNameType, requiredType: ClassType, ...args: any[]): any | undefined { - if (null === name) { + if (undefined === name) { name = requiredType.name; } @@ -105,6 +105,7 @@ export class InstanceFactory implements InstanceDefinitionRegistry { private getSingleton(name: InstanceNameType): any | undefined { let singletonObject = this._singletonObjects.get(name); + return singletonObject; } /** diff --git a/src/ts/@overflow/webapp/config/webapp_configuration.ts b/src/ts/@overflow/webapp/config/webapp_configuration.ts index 191e4cc..d891281 100644 --- a/src/ts/@overflow/webapp/config/webapp_configuration.ts +++ b/src/ts/@overflow/webapp/config/webapp_configuration.ts @@ -3,6 +3,10 @@ import { Instance, } from '@overflow/commons/application/decorators'; import { Value } from '@overflow/commons/di/decorators'; +import { + createHashHistory, + History, +} from 'history'; @Configuration() export class WebAppConfiguration { @@ -10,10 +14,10 @@ export class WebAppConfiguration { private htmlContainerID: string; /** - * container + * containerPromise */ @Instance() - public container(): Promise { + public containerPromise(): Promise { function getContainer(containerID: string): Promise { return new Promise(resolve => { document.addEventListener('DOMContentLoaded', () => { @@ -24,4 +28,13 @@ export class WebAppConfiguration { return getContainer(this.htmlContainerID); } + + /** + * history + */ + @Instance() + public history(): History { + return createHashHistory(); + } + } diff --git a/src/ts/@overflow/webapp/index.tsx b/src/ts/@overflow/webapp/index.tsx index 7e77315..29b74c0 100644 --- a/src/ts/@overflow/webapp/index.tsx +++ b/src/ts/@overflow/webapp/index.tsx @@ -79,12 +79,13 @@ class WebAppApplication extends B { private static isProduction:boolean = process.env.NODE_ENV === 'production' ? true : false; private static useReduxDevTools:boolean = window.devToolsExtension && !WebAppApplication.isProduction ? true : false; - @Value('html.container.id') - private htmlContainerID: string; + @Resource() + private containerPromise: Promise; private container: HTMLElement; @Resource() private store: Store; + @Resource() private history: History; @Inject() @@ -93,7 +94,7 @@ class WebAppApplication extends B { @Runner() public async run(): Promise { try { - this.container = await this.getContainer(); + this.container = await this.containerPromise; this.renderLoading(); let reducer: WebAppDispatcherReducer = new WebAppDispatcherReducer(); reducer.registerReducers(config.redux.reducers); @@ -105,18 +106,6 @@ class WebAppApplication extends B { } } - private getContainer(): Promise { - function getContainer(containerID: string): Promise { - return new Promise(resolve => { - document.addEventListener('DOMContentLoaded', () => { - resolve(document.getElementById(containerID)); - }); - }); - } - - return getContainer(this.htmlContainerID); - } - private renderLoading(): void { ReactDOM.render(