test probe
This commit is contained in:
parent
52eda63df7
commit
de7388bbc1
21
src/ts/@overflow/probe/redux/reducer/readAllByDomain.ts
Normal file
21
src/ts/@overflow/probe/redux/reducer/readAllByDomain.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import Action from '@overflow/commons/redux/Action';
|
||||||
|
import { ReducersMapObject } from 'redux';
|
||||||
|
import Probe from '@overflow/probe/api/model/Probe';
|
||||||
|
|
||||||
|
import * as ReadAllByDomainActionTypes from '../action/read_all_by_domain';
|
||||||
|
import ReadAllProbeByDomainState, { defaultState as readAllProbeByDomainDefaultState } from '../state/ReadAllByDomain';
|
||||||
|
|
||||||
|
const reducer: ReducersMapObject = {
|
||||||
|
[ReadAllByDomainActionTypes.REQUEST_SUCCESS]:
|
||||||
|
(state: ReadAllProbeByDomainState = readAllProbeByDomainDefaultState, action: Action<Probe>):
|
||||||
|
ReadAllProbeByDomainState => {
|
||||||
|
return state;
|
||||||
|
},
|
||||||
|
[ReadAllByDomainActionTypes.REQUEST_FAILURE]:
|
||||||
|
(state: ReadAllProbeByDomainState = readAllProbeByDomainDefaultState, action: Action<Error>):
|
||||||
|
ReadAllProbeByDomainState => {
|
||||||
|
return state;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default reducer;
|
|
@ -1,37 +1,32 @@
|
||||||
import { SagaIterator } from 'redux-saga';
|
import { SagaIterator } from 'redux-saga';
|
||||||
import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects';
|
import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects';
|
||||||
|
import { SagaWatcher } from '@overflow/commons/redux-saga';
|
||||||
import AppContext from '@overflow/commons/context';
|
import AppContext from '@overflow/commons/context';
|
||||||
import Action from '@overflow/commons/redux/Action';
|
import Action from '@overflow/commons/redux/Action';
|
||||||
|
|
||||||
import ProbeService from '../../api/service/ProbeService';
|
import ProbeService from '../../api/service/ProbeService';
|
||||||
import * as ReadAllByDomainActions from '../action/read_all_by_domain';
|
import * as ReadAllByDomainActions from '../action/read_all_by_domain';
|
||||||
import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload';
|
import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload';
|
||||||
|
|
||||||
function* readAllByDomain(action: Action<ReadAllByDomainPayload>): SagaIterator {
|
function* readAllByDomain(action: Action<ReadAllByDomainPayload>): SagaIterator {
|
||||||
try {
|
try {
|
||||||
const {domain} = action.payload;
|
const { domain } = action.payload;
|
||||||
// yield put({
|
|
||||||
// type: types.SENDING_REQUEST,
|
|
||||||
// payload: {sendingRequest: true},
|
|
||||||
// });
|
|
||||||
|
|
||||||
const ret = yield call(AppContext.getService<ProbeService>().readAllByDomain, domain);
|
let service = AppContext.getService(ProbeService);
|
||||||
|
|
||||||
|
const ret = yield call({context: service, fn: service.readAllByDomain}, domain);
|
||||||
|
|
||||||
// if (responseBody.token === undefined) {
|
|
||||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
|
||||||
// }
|
|
||||||
yield put(ReadAllByDomainActions.requestSuccess(ret));
|
yield put(ReadAllByDomainActions.requestSuccess(ret));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
yield put(ReadAllByDomainActions.requestFailure(e));
|
yield put(ReadAllByDomainActions.requestFailure(e));
|
||||||
|
// tslint:disable-next-line:no-empty
|
||||||
} finally {
|
} finally {
|
||||||
// yield put({
|
|
||||||
// type: types.SENDING_REQUEST,
|
|
||||||
// payload: {sendingRequest: false},
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* watchReadAllByDomain(): SagaIterator {
|
export function* watchReadAllByDomain(): SagaIterator {
|
||||||
yield takeLatest(ReadAllByDomainActions.REQUEST, readAllByDomain);
|
yield takeLatest(ReadAllByDomainActions.REQUEST, readAllByDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sagaWatchers: SagaWatcher[] = [watchReadAllByDomain];
|
||||||
|
|
||||||
|
export default sagaWatchers;
|
||||||
|
|
9
src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts
Normal file
9
src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
export interface State {
|
||||||
|
readonly error?: Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defaultState: State = {
|
||||||
|
error: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default State;
|
Loading…
Reference in New Issue
Block a user