本文整理匯總了TypeScript中app/shared/reducers/action-type.util.REQUEST方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript util.REQUEST方法的具體用法?TypeScript util.REQUEST怎麽用?TypeScript util.REQUEST使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app/shared/reducers/action-type.util
的用法示例。
在下文中一共展示了util.REQUEST方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: default
// Reducer
export default (state: SettingsState = initialState, action): SettingsState => {
switch (action.type) {
case REQUEST(ACTION_TYPES.UPDATE_ACCOUNT):
return {
...state,
errorMessage: null,
updateSuccess: false,
loading: true
};
case FAILURE(ACTION_TYPES.UPDATE_ACCOUNT):
return {
...state,
loading: false,
updateSuccess: false,
updateFailure: true
};
case SUCCESS(ACTION_TYPES.UPDATE_ACCOUNT):
return {
...state,
loading: false,
updateSuccess: true,
updateFailure: false
};
case ACTION_TYPES.RESET:
return {
...initialState
};
default:
return state;
}
};
示例2: default
// Reducer
export default (state: RegisterState = initialState, action): RegisterState => {
switch (action.type) {
case REQUEST(ACTION_TYPES.CREATE_ACCOUNT):
return {
...state,
loading: true
};
case FAILURE(ACTION_TYPES.CREATE_ACCOUNT):
return {
...initialState,
registrationFailure: true,
errorMessage: action.payload.response.data.errorKey
};
case SUCCESS(ACTION_TYPES.CREATE_ACCOUNT):
return {
...initialState,
registrationSuccess: true
};
case ACTION_TYPES.RESET:
return {
...initialState
};
default:
return state;
}
};
示例3: it
it('should detect a request', () => {
const toTest = account(undefined, { type: REQUEST(ACTION_TYPES.UPDATE_ACCOUNT) });
expect(toTest).toMatchObject({
updateSuccess: false,
updateFailure: false,
loading: true
});
});
示例4: it
it('should set state to updating', () => {
testMultipleTypes(
[
REQUEST(ACTION_TYPES.CREATE_FLOCKRELATION),
REQUEST(ACTION_TYPES.UPDATE_FLOCKRELATION),
REQUEST(ACTION_TYPES.DELETE_FLOCKRELATION)
],
{},
state => {
expect(state).toMatchObject({
errorMessage: null,
updateSuccess: false,
updating: true
});
}
);
});
示例5: it
it('dispatches FETCH_LOGS_CHANGE_LEVEL_PENDING and FETCH_LOGS_CHANGE_LEVEL_FULFILLED actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.FETCH_LOGS_CHANGE_LEVEL)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_LOGS_CHANGE_LEVEL),
payload: resolvedObject
},
{
type: REQUEST(ACTION_TYPES.FETCH_LOGS)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_LOGS),
payload: resolvedObject
}
];
await store.dispatch(changeLogLevel('ROOT', 'DEBUG')).then(() => expect(store.getActions()).toEqual(expectedActions));
});
示例6: it
it('dispatches DELETE_USER_PENDING and DELETE_USER_FULFILLED actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.DELETE_USER)
},
{
type: SUCCESS(ACTION_TYPES.DELETE_USER),
payload: resolvedObject
},
{
type: REQUEST(ACTION_TYPES.FETCH_USERS)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_USERS),
payload: resolvedObject
}
];
await store.dispatch(deleteUser('admin')).then(() => expect(store.getActions()).toEqual(expectedActions));
});
示例7: it
it('dispatches ACTION_TYPES.CREATE_DIALOGUE actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.CREATE_DIALOGUE)
},
{
type: SUCCESS(ACTION_TYPES.CREATE_DIALOGUE),
payload: resolvedObject
},
{
type: REQUEST(ACTION_TYPES.FETCH_DIALOGUE_LIST)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_DIALOGUE_LIST),
payload: resolvedObject
}
];
await store.dispatch(createEntity({ id: 1 })).then(() => expect(store.getActions()).toEqual(expectedActions));
});
示例8: it
it('dispatches ACTION_TYPES.UPDATE_CUSTOMER actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.UPDATE_CUSTOMER)
},
{
type: SUCCESS(ACTION_TYPES.UPDATE_CUSTOMER),
payload: resolvedObject
},
{
type: REQUEST(ACTION_TYPES.FETCH_CUSTOMER_LIST)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_CUSTOMER_LIST),
payload: resolvedObject
}
];
await store.dispatch(updateEntity({ id: 1 })).then(() => expect(store.getActions()).toEqual(expectedActions));
});
示例9: it
it('dispatches ACTION_TYPES.FETCH_HISTORYMESSAGE actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.FETCH_HISTORYMESSAGE)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_HISTORYMESSAGE),
payload: resolvedObject
}
];
await store.dispatch(getEntity(42666)).then(() => expect(store.getActions()).toEqual(expectedActions));
});