本文整理匯總了TypeScript中redux-actions.createAction函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createAction函數的具體用法?TypeScript createAction怎麽用?TypeScript createAction使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了createAction函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createNetworkAction
export function createNetworkAction(prefix: string): NetworkAction {
return {
start: createAction(`${prefix}_START`),
error: createAction(`${prefix}_ERROR`),
complete: createAction(`${prefix}_COMPLETE`),
}
}
示例2: function
const actions = function(ajax, todoUrl) {
return {
loadTodos: createAction("ACTION_LIST", () => ({promise: ajax.getJSON(todoUrl.get)})),
editTodo: createAction("ACTION_EDIT"),
deleteTodo: createAction("ACTION_DELETE",
todo => ({promise: ajax.deleteJSON(todoUrl.delete(todo.id))}))
};
};
示例3: return
return (actionType: string,
payloadCreator?: (...args: any[]) => Payload,
metaCreator?: (...args: any[]) => Meta) => {
const actionCreator = createAction<Payload, Meta>(actionType, payloadCreator, metaCreator);
return createMultiTypeGetter<typeof actionCreator, StatusTypes>(actionCreator, actionStatusWrappers)(actionType);
};
示例4: Promise
return new Promise( (resolve, reject) => {
const notifyRequestingAction = createAction(type, () => { return {}; }, () => { return { pending: true }; });
dispatch(notifyRequestingAction());
return promise(args).then( (result) => {
const actionSuccess = createAction(type);
dispatch(actionSuccess(result));
resolve(result);
}).catch( (error) => {
const actionError = createAction(type, () => { return error; });
dispatch(actionError(error));
reject(error.message);
});
});
示例5: createAction
export function createAction(type: string, payloadCreator, metaCreator) {
type = `$SOS_${type}`
const actionCreator = _createAction(type, payloadCreator, metaCreator)
const creator = (...args) => {
const action = actionCreator(...args)
if (typeof action.payload === 'function') {
return Object.assign(action, {args})
}
return action
}
return Object.assign(creator, {
toString: actionCreator.toString,
payload(payload) {
return {type, payload}
},
reply(args, result) {
return {type, payload: {args, result}}
}
})
}
示例6: createAction
///<reference path="../../../typings/browser.d.ts"/>
/**
*
* Created by hanrui on 2016/3/1.
*/
import {createAction, handleAction, handleActions} from 'redux-actions'
import {message} from 'antd'
import {push} from 'react-router-redux'
const UPDATE_UNLEARNED_STUDY = createAction('UPDATE_UNLEARNED_STUDY')
const UPDATE_LEARNED_STUDY = createAction('UPDATE_LEARNED_STUDY')
const get_unlearn_department_study = (): ReduxThunk.ThunkInterface => {
return (dispatch, state) => {
const url = '/api/study/get-unlearned-study/'
fetch(url, {
credentials: 'include',
}).then(response => {
if (response.status == 200) {
response.json().then(json => dispatch(UPDATE_UNLEARNED_STUDY(json)))
} else {
response.json().then(json => {
message.error(JSON.parse(json))
})
}
})
}
}
const SHOW_ADD_STUDY_MODAL = createAction("SHOW_ADD_STUDY_MODAL")
const add_study = (question:string, answer:string = ''):ReduxThunk.ThunkInterface => {
return (dispatch, state) => {
const url = '/api/study/professional-study/'
fetch(url, {
示例7: createAction
import { createAction, handleActions } from 'redux-actions'
export enum ACTION_TYPES {
TOGGLE_STATUS_SERVICES = '@ReactiveTraderCloud/TOGGLE_STATUS_SERVICES',
OPEN_LINK = '@ReactiveTraderCloud/FOOTER_OPEN_LINK',
}
export const toggleStatusServices = createAction(ACTION_TYPES.TOGGLE_STATUS_SERVICES)
export const openLinks = createAction(ACTION_TYPES.OPEN_LINK, payload => payload)
const INITIAL_STATE = false
export const footerEpic = openFin => (action$) => {
return action$.ofType(ACTION_TYPES.OPEN_LINK)
.map(action => openLinks(openFin))
}
export default handleActions(
{
[ACTION_TYPES.TOGGLE_STATUS_SERVICES]: state => !state,
},
INITIAL_STATE)
示例8:
* specific language governing permissions and limitations
* under the License.
*/
/* eslint-disable @typescript-eslint/no-empty-interface */
import { createAction } from 'redux-actions';
import { KibanaAction } from '../../selectors/types';
export enum MetadataActionTypeKeys {
UPDATE_DESCRIPTION = 'UPDATE_DESCRIPTION',
UPDATE_TITLE = 'UPDATE_TITLE',
}
export type UpdateTitleActionPayload = string;
export interface UpdateTitleAction
extends KibanaAction<MetadataActionTypeKeys.UPDATE_TITLE, UpdateTitleActionPayload> {}
export type UpdateDescriptionActionPayload = string;
export interface UpdateDescriptionAction
extends KibanaAction<MetadataActionTypeKeys.UPDATE_DESCRIPTION, UpdateDescriptionActionPayload> {}
export type MetadataActions = UpdateDescriptionAction | UpdateTitleAction;
export const updateDescription = createAction<UpdateDescriptionAction>(
MetadataActionTypeKeys.UPDATE_DESCRIPTION
);
export const updateTitle = createAction<UpdateTitleAction>(MetadataActionTypeKeys.UPDATE_TITLE);
示例9:
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { createAction } from 'redux-actions';
import { HotKey } from '../components/shortcuts';
export const registerShortcut = createAction<HotKey>('REGISTER SHORTCUT');
export const unregisterShortcut = createAction<HotKey>('UNREGISTER SHORTCUT');
export const toggleHelp = createAction<boolean | null>('TOGGLE SHORTCUTS HELP');