ing
This commit is contained in:
parent
05f949fd3a
commit
d2c6a7b3b7
|
@ -108,14 +108,14 @@ class OFApplication {
|
||||||
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);
|
// resolve(client);
|
||||||
});
|
});
|
||||||
|
|
||||||
return rpcClient;
|
return rpcClient;
|
||||||
|
@ -144,16 +144,21 @@ class OFApplication {
|
||||||
OFApplication.useReduxDevTools ? compose(middleware, window.devToolsExtension()) : middleware,
|
OFApplication.useReduxDevTools ? compose(middleware, window.devToolsExtension()) : middleware,
|
||||||
);
|
);
|
||||||
// saga
|
// saga
|
||||||
this.sagaMiddleware.run(this.initReduxSagaWarchers, this.config.redux.sagaWarchers);
|
this.sagaMiddleware.run(this.initReduxSagaWarchers, this.config.redux.sagaWarchers, this.rpcClient);
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
return init;
|
return init;
|
||||||
}
|
}
|
||||||
|
|
||||||
private * initReduxSagaWarchers(sagaWarchers: Class<SagaWatcher>[]): SagaIterator {
|
private * initReduxSagaWarchers(sagaWarchers: Class<SagaWatcher>[], rpcClient: WebSocketRPC): SagaIterator {
|
||||||
for (let Watcher of sagaWarchers) {
|
for (let type of sagaWarchers) {
|
||||||
let instance = new Watcher();
|
|
||||||
|
let instance = Object.create(type.prototype);
|
||||||
|
instance.constructor.call(instance);
|
||||||
|
if (type.prototype.hasOwnProperty('setWebSocketRPC')) {
|
||||||
|
instance.setWebSocketRPC.call(instance, rpcClient);
|
||||||
|
}
|
||||||
yield fork({context: instance, fn: instance.watch});
|
yield fork({context: instance, fn: instance.watch});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,21 @@ import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher';
|
||||||
|
|
||||||
|
|
||||||
export class AsyncRequest implements SagaWatcher {
|
export class AsyncRequest implements SagaWatcher {
|
||||||
private webSocketRPC: WebSocketRPC;
|
private _webSocketRPC: WebSocketRPC;
|
||||||
|
|
||||||
private * request(action: Action<AsyncRequestPayload>): SagaIterator {
|
public setWebSocketRPC(webSocketRPC: WebSocketRPC): void {
|
||||||
|
this._webSocketRPC = webSocketRPC;
|
||||||
|
}
|
||||||
|
|
||||||
|
private * request(webSocketRPC: WebSocketRPC, action: Action<AsyncRequestPayload>): SagaIterator {
|
||||||
const {service, method, requestType, args} = action.payload;
|
const {service, method, requestType, args} = action.payload;
|
||||||
try {
|
try {
|
||||||
// yield put({
|
// yield put({
|
||||||
// type: types.SENDING_REQUEST,
|
// type: types.SENDING_REQUEST,
|
||||||
// payload: {sendingRequest: true},
|
// payload: {sendingRequest: true},
|
||||||
// });`${service}.${method}`
|
// });`${service}.${method}`
|
||||||
// let webSocketRPC: WebSocketRPC = GetAppContext().getPouchByClass(WebSocketRPC.prototype, undefined);
|
|
||||||
let result = yield call({context: this.webSocketRPC, fn: this.webSocketRPC.Call}, `${service}.${method}`, args);
|
let result = yield call({context: webSocketRPC, fn: webSocketRPC.Call}, `${service}.${method}`, args);
|
||||||
|
|
||||||
// yield put(AsyncRequestActions.requestSuccess(requestType, result));
|
// yield put(AsyncRequestActions.requestSuccess(requestType, result));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -35,7 +39,7 @@ export class AsyncRequest implements SagaWatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public * watch(): SagaIterator {
|
public * watch(): SagaIterator {
|
||||||
yield takeEvery(AsyncRequestActions.REQUEST, this.request);
|
yield takeEvery(AsyncRequestActions.REQUEST, this.request, this._webSocketRPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import State from '../redux/state/SignIn';
|
||||||
|
|
||||||
import * as signinActions from '../redux/action/signIn';
|
import * as signinActions from '../redux/action/signIn';
|
||||||
|
|
||||||
|
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
||||||
|
|
||||||
export function mapStateToProps(state: any, ownProps?: any): SignInStateProps {
|
export function mapStateToProps(state: any, ownProps?: any): SignInStateProps {
|
||||||
return {
|
return {
|
||||||
|
@ -19,6 +20,7 @@ export function mapDispatchToProps(dispatch: Dispatch<any>, ownProps?: any): Sig
|
||||||
return {
|
return {
|
||||||
onSignIn: (signinId: string, signinPw: string) => {
|
onSignIn: (signinId: string, signinPw: string) => {
|
||||||
// dispatch(signinActions.request(signinId, signinPw));
|
// dispatch(signinActions.request(signinId, signinPw));
|
||||||
|
dispatch(asyncRequestActions.request('MemberService', 'signin', signinActions.REQUEST, signinId, signinPw));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user