This commit is contained in:
Byung Jun Park 2017-07-28 02:55:14 +09:00
parent 562edb920d
commit cf8037063a
21 changed files with 58 additions and 45 deletions

View File

@ -24,7 +24,7 @@ const rpcConfig: RPCConfig = {
export interface ReduxConfig { export interface ReduxConfig {
state: ReduxState; state: ReduxState;
reducerMaps: ReducersMapObject[]; reducerMaps: ReducersMapObject[];
sagaWarchers: (SagaWatcher[])[]; sagaWarchers: SagaWatcher[];
} }
export interface ReduxState { export interface ReduxState {
@ -39,7 +39,7 @@ const reduxConfig: ReduxConfig = {
signInReducer, signInReducer,
], ],
sagaWarchers: [ sagaWarchers: [
signInSagaWatchers, ...signInSagaWatchers,
], ],
}; };

View File

@ -86,8 +86,8 @@ class Application {
this.displayLoading(); this.displayLoading();
this.context = await this.initContext(); this.context = await this.initContext();
// this.rpcClient = await this.initRpcClient(); this.rpcClient = await this.initRpcClient();
// this.context.PouchFactory.registerPouch(this.rpcClient); this.context.PouchFactory.registerPouch(this.rpcClient);
await this.initRedux(); await this.initRedux();
@ -112,13 +112,14 @@ class Application {
private initRpcClient(): Promise<WebSocketRPC> { private initRpcClient(): Promise<WebSocketRPC> {
const rpcClient = new Promise<WebSocketRPC>((resolve, reject) => { const rpcClient = new Promise<WebSocketRPC>((resolve, reject) => {
let client = new WebSocketRPC(this.config.rpc.url); let client = new WebSocketRPC(this.config.rpc.url);
client.initialize() // client.initialize()
.then(() => { // .then(() => {
resolve(client); // resolve(client);
}) // })
.catch((err: any) => { // .catch((err: any) => {
reject(err); // reject(err);
}); // });
resolve(client);
}); });
return rpcClient; return rpcClient;
@ -154,11 +155,9 @@ class Application {
return init; return init;
} }
private * initReduxSagaWarchers(sagaWarchers: (SagaWatcher[])[]): SagaIterator { private * initReduxSagaWarchers(sagaWarchers: SagaWatcher[]): SagaIterator {
for (let sagaWarcher of sagaWarchers) { for (let sagaWarcher of sagaWarchers) {
for (let warcher of sagaWarcher) { yield fork(sagaWarcher);
yield fork(warcher);
}
} }
} }

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class TargetDetail extends React.Component<RouteComponentProps<object>, object> { class TargetDetail extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class TargetList extends React.Component<RouteComponentProps<object>, object> { class TargetList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class SignOut extends React.Component<RouteComponentProps<object>, object> { class SignOut extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {
@ -21,7 +21,7 @@ class SignOut extends React.Component<RouteComponentProps<object>, object> {
); );
} }
private test(@inject() c: WebSocketRPC): void { private test( c: WebSocketRPC): void {
console.log(''); console.log('');
} }
} }

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class ProbeDetail extends React.Component<RouteComponentProps<object>, object> { class ProbeDetail extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {

View File

@ -5,7 +5,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class ProbeHistory extends React.Component<RouteComponentProps<object>, object> { class ProbeHistory extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class ProbeHost extends React.Component<RouteComponentProps<object>, object> { class ProbeHost extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class ProbeList extends React.Component<RouteComponentProps<object>, object> { class ProbeList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class ProbeList extends React.Component<RouteComponentProps<object>, object> { class ProbeList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class ProbeList extends React.Component<RouteComponentProps<object>, object> { class ProbeList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class SensorDetail extends React.Component<RouteComponentProps<object>, object> { class SensorDetail extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {
@ -21,7 +21,7 @@ class SensorDetail extends React.Component<RouteComponentProps<object>, object>
); );
} }
private test(@inject() c: WebSocketRPC): void { private test( c: WebSocketRPC): void {
console.log(''); console.log('');
} }
} }

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class SensorDetailInfo extends React.Component<RouteComponentProps<object>, object> { class SensorDetailInfo extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {
@ -21,7 +21,7 @@ class SensorDetailInfo extends React.Component<RouteComponentProps<object>, obje
); );
} }
private test(@inject() c: WebSocketRPC): void { private test( c: WebSocketRPC): void {
console.log(''); console.log('');
} }
} }

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class SensorDetailItems extends React.Component<RouteComponentProps<object>, object> { class SensorDetailItems extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {
@ -21,7 +21,7 @@ class SensorDetailItems extends React.Component<RouteComponentProps<object>, obj
); );
} }
private test(@inject() c: WebSocketRPC): void { private test( c: WebSocketRPC): void {
console.log(''); console.log('');
} }
} }

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class SensorItemTree extends React.Component<RouteComponentProps<object>, object> { class SensorItemTree extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {
@ -21,7 +21,7 @@ class SensorItemTree extends React.Component<RouteComponentProps<object>, object
); );
} }
private test(@inject() c: WebSocketRPC): void { private test( c: WebSocketRPC): void {
console.log(''); console.log('');
} }
} }

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class SensorList extends React.Component<RouteComponentProps<object>, object> { class SensorList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {
@ -21,7 +21,7 @@ class SensorList extends React.Component<RouteComponentProps<object>, object> {
); );
} }
private test(@inject() c: WebSocketRPC): void { private test( c: WebSocketRPC): void {
console.log(''); console.log('');
} }
} }

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class SensorSetup extends React.Component<RouteComponentProps<object>, object> { class SensorSetup extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {
@ -21,7 +21,7 @@ class SensorSetup extends React.Component<RouteComponentProps<object>, object> {
); );
} }
private test(@inject() c: WebSocketRPC): void { private test(c: WebSocketRPC): void {
console.log(''); console.log('');
} }
} }

View File

@ -5,16 +5,23 @@ import PouchInjectDefinition from '../config/PouchInjectDefinition';
const Inject = (injectConfig: InjectConfig = {}) => { const Inject = (injectConfig: InjectConfig = {}) => {
return (...args: any[]) => { return (...args: any[]) => {
switch(args.length) { let params = [];
for (let i = 0; i < args.length; i++) {
if (args[i]) {
params.push(args[i]);
}
}
switch(params.length) {
case 1: case 1:
return injectClass.apply(this, args); return injectClass(injectConfig).apply(this, args);
case 2: case 2:
return injectProperty.apply(this, args); return injectProperty(injectConfig).apply(this, args);
case 3: case 3:
if(typeof args[2] === 'number') { if(typeof args[2] === 'number') {
return injectParameter.apply(this, args); return injectParameter(injectConfig).apply(this, args);
} }
return injectMethod.apply(this, args); return injectMethod(injectConfig).apply(this, args);
default: default:
throw new Error('@Inject decorators are not valid here!'); throw new Error('@Inject decorators are not valid here!');
} }

View File

@ -3,7 +3,14 @@ import PouchDefinition from '../config/PouchDefinition';
const Injectable = (...args: any[]) => { const Injectable = (...args: any[]) => {
switch(args.length) { let params = [];
for (let i = 0; i < args.length; i++) {
if (args[i]) {
params.push(args[i]);
}
}
switch(params.length) {
case 1: case 1:
return injectableClass.apply(this, args); return injectableClass.apply(this, args);
case 2: case 2:

View File

@ -48,7 +48,7 @@ class PouchFactory {
* registerPouch * registerPouch
*/ */
public registerPouch(pouch: any, qualifier: string | symbol = POUCH_DEFAULT_QUALIFIER): void { public registerPouch(pouch: any, qualifier: string | symbol = POUCH_DEFAULT_QUALIFIER): void {
let clazz = pouch.prototype; let clazz = Object.getPrototypeOf(pouch);
this._putPouchInstance(clazz, qualifier, pouch); this._putPouchInstance(clazz, qualifier, pouch);
} }

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject'; import inject from '@overflow/commons/context/decorator/inject';
class Discovery extends React.Component<RouteComponentProps<object>, object> { class Discovery extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC; private client: WebSocketRPC;
public constructor(props?: RouteComponentProps<object>, context?: object) { public constructor(props?: RouteComponentProps<object>, context?: object) {