diff --git a/src/ts/@overflow/app/redux/action/asyncRequestSending.ts b/src/ts/@overflow/app/redux/action/asyncRequestSending.ts new file mode 100644 index 0000000..f02378c --- /dev/null +++ b/src/ts/@overflow/app/redux/action/asyncRequestSending.ts @@ -0,0 +1,18 @@ +import Action from '@overflow/commons/redux/Action'; +import AsyncRequestSendingPayload from '../payload/AsyncRequestSendingPayload'; + +// Action Type +export type SENDING = '@overflow/app/async/SENDING'; +export const SENDING: SENDING = '@overflow/app/async/SENDING'; + +// Action Creater +export type sending = (complete: boolean) => Action; + +export const sending: sending = (complete: boolean): Action => { + return { + type: SENDING, + payload: { + complete: complete, + }, + }; +}; diff --git a/src/ts/@overflow/app/redux/payload/AsyncRequestSendingPayload.ts b/src/ts/@overflow/app/redux/payload/AsyncRequestSendingPayload.ts new file mode 100644 index 0000000..31da865 --- /dev/null +++ b/src/ts/@overflow/app/redux/payload/AsyncRequestSendingPayload.ts @@ -0,0 +1,5 @@ +export interface AsyncRequestSendingPayload { + complete: boolean; +} + +export default AsyncRequestSendingPayload; diff --git a/src/ts/@overflow/app/redux/reducer/asyncRequestSending.ts b/src/ts/@overflow/app/redux/reducer/asyncRequestSending.ts new file mode 100644 index 0000000..e6e7d9e --- /dev/null +++ b/src/ts/@overflow/app/redux/reducer/asyncRequestSending.ts @@ -0,0 +1,20 @@ +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import AsyncRequestSendingPayload from '../payload/AsyncRequestSendingPayload'; + +import * as AsyncRequestSendingActions from '../action/asyncRequestSending'; + +import AsyncRequestSendingState, { + defaultState as AsyncRequestSendingDefaultState, +} from '../state/AsyncRequestSending'; + +const reducer: ReducersMapObject = { + [AsyncRequestSendingActions.SENDING]: (state: AsyncRequestSendingState = AsyncRequestSendingDefaultState, + action: Action): AsyncRequestSendingState => { + return { + complete: action.payload.complete, + }; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/app/redux/saga/AsyncRequest.ts b/src/ts/@overflow/app/redux/saga/AsyncRequest.ts index 81c6574..773cf01 100644 --- a/src/ts/@overflow/app/redux/saga/AsyncRequest.ts +++ b/src/ts/@overflow/app/redux/saga/AsyncRequest.ts @@ -2,13 +2,13 @@ import { SagaIterator } from 'redux-saga'; import { call, Effect, fork, put, takeEvery } from 'redux-saga/effects'; import Action from '@overflow/commons/redux/Action'; +import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher'; import * as AsyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; +import AsyncRequestPayload from '@overflow/commons/redux/payload/AsyncRequestPayload'; import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC'; -import AsyncRequestPayload from '@overflow/commons/redux/payload/AsyncRequestPayload'; -import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher'; - +import * as AppAsyncRequestSendingActions from '../action/asyncRequestSending'; export class AsyncRequest implements SagaWatcher { private _webSocketRPC: WebSocketRPC; @@ -20,10 +20,7 @@ export class AsyncRequest implements SagaWatcher { private * request(webSocketRPC: WebSocketRPC, action: Action): SagaIterator { const {service, method, requestType, args} = action.payload; try { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // });`${service}.${method}` + yield put(AppAsyncRequestSendingActions.sending(false)); let result = yield call({context: webSocketRPC, fn: webSocketRPC.Call}, `${service}.${method}`, args); @@ -31,10 +28,7 @@ export class AsyncRequest implements SagaWatcher { } catch (e) { yield put(AsyncRequestActions.requestFailure(requestType, e)); } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); + yield put(AppAsyncRequestSendingActions.sending(true)); } } diff --git a/src/ts/@overflow/app/redux/state/AsyncRequestSending.ts b/src/ts/@overflow/app/redux/state/AsyncRequestSending.ts new file mode 100644 index 0000000..6948d64 --- /dev/null +++ b/src/ts/@overflow/app/redux/state/AsyncRequestSending.ts @@ -0,0 +1,9 @@ +export interface State { + complete: boolean; +} + +export const defaultState: State = { + complete: false, +}; + +export default State; diff --git a/src/ts/@overflow/commons/redux/action/asyncRequest.ts b/src/ts/@overflow/commons/redux/action/asyncRequest.ts index 303f5e9..4d4648a 100644 --- a/src/ts/@overflow/commons/redux/action/asyncRequest.ts +++ b/src/ts/@overflow/commons/redux/action/asyncRequest.ts @@ -2,9 +2,8 @@ import Action from '@overflow/commons/redux/Action'; import AsyncRequestPayload from '../payload/AsyncRequestPayload'; // Action Type -export type REQUEST = '@@overflow/anync/REQUEST'; - -export const REQUEST: REQUEST = '@@overflow/anync/REQUEST'; +export type REQUEST = '@overflow/commons/anync/REQUEST'; +export const REQUEST: REQUEST = '@overflow/commons/anync/REQUEST'; // Action Creater export type request = (service: string, method: string, requestType: string, ...args: any[]) => Action;