本文整理汇总了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');