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 {
state: ReduxState;
reducerMaps: ReducersMapObject[];
sagaWarchers: (SagaWatcher[])[];
sagaWarchers: SagaWatcher[];
}
export interface ReduxState {
@ -39,7 +39,7 @@ const reduxConfig: ReduxConfig = {
signInReducer,
],
sagaWarchers: [
signInSagaWatchers,
...signInSagaWatchers,
],
};

View File

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

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject';
class TargetDetail extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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';
class TargetList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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';
class SignOut extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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('');
}
}

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject';
class ProbeDetail extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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';
class ProbeHistory extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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';
class ProbeHost extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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';
class ProbeList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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';
class ProbeList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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';
class ProbeList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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';
class SensorDetail extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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('');
}
}

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject';
class SensorDetailInfo extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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('');
}
}

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject';
class SensorDetailItems extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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('');
}
}

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject';
class SensorItemTree extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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('');
}
}

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject';
class SensorList extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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('');
}
}

View File

@ -6,7 +6,7 @@ import AppContext from '@overflow/commons/context';
import inject from '@overflow/commons/context/decorator/inject';
class SensorSetup extends React.Component<RouteComponentProps<object>, object> {
@inject()
private client: WebSocketRPC;
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('');
}
}

View File

@ -5,16 +5,23 @@ import PouchInjectDefinition from '../config/PouchInjectDefinition';
const Inject = (injectConfig: InjectConfig = {}) => {
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:
return injectClass.apply(this, args);
return injectClass(injectConfig).apply(this, args);
case 2:
return injectProperty.apply(this, args);
return injectProperty(injectConfig).apply(this, args);
case 3:
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:
throw new Error('@Inject decorators are not valid here!');
}

View File

@ -3,7 +3,14 @@ import PouchDefinition from '../config/PouchDefinition';
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:
return injectableClass.apply(this, args);
case 2:

View File

@ -48,7 +48,7 @@ class PouchFactory {
* registerPouch
*/
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);
}

View File

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