本文整理匯總了TypeScript中typescript-fsa.actionCreatorFactory函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript actionCreatorFactory函數的具體用法?TypeScript actionCreatorFactory怎麽用?TypeScript actionCreatorFactory使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了actionCreatorFactory函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: actionCreatorFactory
export const createGraphqlOperationActionCreators = <Data, Variables, Error = ApolloError>(
stateKey: string,
operationKey: string
): OperationActionCreators<Data, Variables, Error> => {
const actionCreator = actionCreatorFactory(`x-pack/infra/remote/${stateKey}/${operationKey}`);
const resolve = actionCreator<Variables>('RESOLVE');
const resolveEffect = actionCreator.async<Variables, ApolloQueryResult<Data>>('RESOLVE');
return {
resolve,
resolveStarted: resolveEffect.started,
resolveDone: resolveEffect.done,
resolveFailed: resolveEffect.failed,
};
};
示例2: actionCreatorFactory
import { CreateNodeBalancerPayload } from 'src/services/nodebalancers';
import { actionCreatorFactory } from 'typescript-fsa';
const actionCreator = actionCreatorFactory(`@@manager/nodeBalancer`);
export interface BalancerParams {
nodeBalancerId: number;
}
type Entity = Linode.NodeBalancer;
export const getAllNodeBalancersActions = actionCreator.async<
void,
Linode.NodeBalancer[],
Linode.ApiFieldError[]
>(`get-all`);
export type CreateNodeBalancerParams = CreateNodeBalancerPayload;
export const createNodeBalancersActions = actionCreator.async<
CreateNodeBalancerParams,
Entity,
Linode.ApiFieldError[]
>(`create`);
/** We require the ID in the action, if we just did Partial<NB> that makes id number | undefined */
export type UpdateNodeBalancerParams = BalancerParams & Partial<Entity>;
export const updateNodeBalancersActions = actionCreator.async<
UpdateNodeBalancerParams,
Entity,
示例3: actionCreatorFactory
import { getRegions } from 'src/services/misc';
import { actionCreatorFactory } from 'typescript-fsa';
import { ThunkActionCreator } from '../types';
const actionCreator = actionCreatorFactory(`@@manager/regions`);
export const regionsRequestActions = actionCreator.async<void, Linode.Region[], Linode.ApiFieldError[]>(`request`);
export const requestRegions: ThunkActionCreator<Promise<Linode.Region[]>> = () => (dispatch) => {
dispatch(regionsRequestActions.started());
return getRegions()
.then(({ data }) => {
dispatch(regionsRequestActions.done({ result: data }));
return data;
})
.catch((error) => {
dispatch(regionsRequestActions.failed({ error }));
return error;
});
}
示例4: actionCreatorFactory
import * as R from 'ramda';
import { ThunkAction } from 'redux-thunk';
import { actionCreatorFactory } from 'typescript-fsa';
import { reducerWithInitialState } from 'typescript-fsa-reducers';
import { gainMana, restoreMana } from './Board/Hero/actions';
import { Game, getDeck, State } from '../Game';
import { activeHero, getOpponent, getPlayer, other } from '../Hero';
import initialState from './initialState';
import { drawCard } from './Deck/deckReducer';
import { selectCards } from '../Card';
import { PlayState, Step } from '../enums';
const actionCreator = actionCreatorFactory();
export const finishGame = actionCreator('FINISH_GAME');
export const nextTurn = actionCreator('NEXT_TURN');
const finishGameHandler = R.evolve<State>({
step: () => Step.FinalGameOver,
});
const nextTurnHandler = R.evolve<State>({
turn: R.inc,
activePlayer: other,
});
export const checkForEndGame = (): ThunkAction<void, Game, {}> => (
dispatch,
getState
) => {
const state = getState();
示例5: actionCreatorFactory
import {
BucketRequestPayload,
DeleteBucketRequestPayload
} from 'src/services/objectStorage/buckets';
import { actionCreatorFactory } from 'typescript-fsa';
export const actionCreator = actionCreatorFactory('@@manager/buckets');
export const createBucketActions = actionCreator.async<
BucketRequestPayload,
Linode.Bucket,
Linode.ApiFieldError[]
>(`create`);
export const getAllBucketsActions = actionCreator.async<
{},
Linode.Bucket[],
Linode.ApiFieldError[]
>('get-all');
export const deleteBucketActions = actionCreator.async<
DeleteBucketRequestPayload,
{},
Linode.ApiFieldError[]
>('delete');
示例6: actionCreatorFactory
import { actionCreatorFactory } from "typescript-fsa";
import { ICardSet } from "../../model/cards";
import { SessionMode, SessionSource } from "../../model/session";
import { IIteration, ITeam } from "../../services/teams";
const factory = actionCreatorFactory("create");
export const init = factory<number[] | undefined>("init");
export const reset = factory<void>("reset");
export const setName = factory<string>("setName");
export const setMode = factory<SessionMode>("setMode");
export const setSource = factory<SessionSource>("setSource");
export const setCardSets = factory<ICardSet[]>("setCardSets");
export const setCardSet = factory<string>("setCardSet");
export const setTeams = factory<ITeam[]>("setTeams");
export const setTeam = factory<string>("setTeam");
export const setIterations = factory<IIteration[]>("setIterations");
export const setIteration = factory<string>("setIteration");
export const setQuery = factory<string>("setQuery");
export const create = factory<void>("create");
示例7: actionCreatorFactory
import { actionCreatorFactory } from 'typescript-fsa';
const actionCreator = actionCreatorFactory(`@@manager/profile`);
export const getProfileActions = actionCreator.async<
void,
Linode.Profile,
Linode.ApiFieldError[]
>(`request`);
export const handleUpdate = actionCreator<
Partial<Linode.Profile> | Partial<Linode.User>
>(`update`);
示例8: actionCreatorFactory
import { actionCreatorFactory } from "typescript-fsa";
import { ISession } from "../../model/session";
import { IIteration, ITeam } from "../../services/teams";
import { ILookup } from "../../lib/lookup";
import { IQuery } from "../../model/query";
const factory = actionCreatorFactory("sessions");
export const loadSessions = factory<void>("load");
export const deleteSession = factory<string>("delete");
export const populate = factory<{
sessions: ISession[];
legacySessions: ISession[];
}>("populate");
export const setIterationLookup = factory<ILookup<IIteration>>(
"setIterationLookup"
);
export const setTeamLookup = factory<ILookup<ITeam>>("setTeamLookup");
export const setQueryLookup = factory<ILookup<IQuery>>("setQueryLookup");
export const filter = factory<string>("filter");
export const fatalError = factory<string>("error");
export const clearError = factory<void>("clearError");
示例9: actionCreatorFactory
import { actionCreatorFactory } from "typescript-fsa";
import { IIdentity } from "./model/identity";
const factory = actionCreatorFactory("init");
export const init = factory<{
identity: IIdentity;
}>("init");
示例10: actionCreatorFactory
import { LinodeDiskCreationData } from 'src/services/linodes';
import { actionCreatorFactory } from 'typescript-fsa';
import { Entity } from './disk.types';
const actionCreator = actionCreatorFactory(`@@manager/linodeDisks`);
type Error = Linode.ApiFieldError[];
interface LinodeIdParam {
linodeId: number;
}
interface DiskIdParam {
diskId: number;
}
export type LinodeDiskCreateFields = LinodeDiskCreationData;
export interface LinodeDiskUpdateFields {
label: string;
}
/** Get Linode Disk (page) */
export type GetLinodeDisksParams = LinodeIdParam;
export type GetLinodeDisksResponse = Promise<Entity[]>;
export type GetLinodeDisksRequest = (
params: GetLinodeDisksParams
) => GetLinodeDisksResponse;