当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript typesafe-actions.createAction函数代码示例

本文整理汇总了TypeScript中typesafe-actions.createAction函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createAction函数的具体用法?TypeScript createAction怎么用?TypeScript createAction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createAction函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createAction

import {createAction} from 'typesafe-actions'

import * as CST from '../../constants'
import {BookmarkTree} from '../../types'

export const addCurrentPage = createAction(
  'ADD_CURRENT_PAGE',
  (action) => (parentId: string, index: number) => action({parentId, index})
)

export const addSeparator = createAction(
  'ADD_SEPARATOR',
  (action) => (parentId: string, index: number) => action({parentId, index})
)

export const copyBookmark = createAction('COPY_BOOKMARK', (action) => (id: string) => action({id}))

export const createBookmark = createAction(
  'CREATE_BOOKMARK',
  (action) => (parentId: string, index: number, title: string, url: string) =>
    action({
      parentId,
      index,
      title,
      url
    })
)

export const createBookmarkAfterId = createAction(
  'CREATE_BOOKMARK_AFTER_ID',
  (action) => (id: string, title: string, url: string) =>
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:31,代码来源:actions.ts

示例2: createAction

import { createAction } from "typesafe-actions";
import { Project } from "./reducer";

export const fetchProjectsRequest = createAction(
  "projects/FETCH_PROJECTS_REQUEST"
);

export const fetchProjectsSuccess = createAction(
  "projects/FETCH_PROJECTS_SUCCESS",
  resolve => {
    return (projects: Project[]) => resolve({ projects });
  }
);

export const fetchProjectsError = createAction("projects/FETCH_PROJECTS_ERROR");
开发者ID:esseb,项目名称:scheduler,代码行数:15,代码来源:actions.ts

示例3: createAction

import {createAction} from 'typesafe-actions'

import {NAV_MODULE} from '../../constants'

export const switchNavModule = createAction(
  'SWITCH_NAV_MODULE',
  (action) => (navModule: NAV_MODULE) =>
    action({
      navModule
    })
)
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:11,代码来源:actions.ts

示例4: createAction

    type?: 'default' | 'success' | 'warning' | 'danger'
}

export interface ITriggerNotificationAction {
    type: NotificationsActionTypes.TRIGGER_NOTIFICATION
    payload: {
        notification: INotification
    }
}

export const triggerNotification = createAction(
    NotificationsActionTypes.TRIGGER_NOTIFICATION,
    resolve => (
        notification: ITriggerNotification
    ) => resolve({
        notification: {
            id: uuid(),
            type: 'default',
            ...notification,
        },
    })
)

export interface ICloseNotificationAction {
    type: NotificationsActionTypes.CLOSE_NOTIFICATION
    payload: {
        notificationId: string
    }
}

export const closeNotification = (
    notificationId: string
开发者ID:manishshanker,项目名称:wiremock-ui,代码行数:32,代码来源:actions.ts

示例5: createAction

import {ActionType, createAction, createReducer} from 'typesafe-actions'

export interface WindowsState {
  activeWindowId?: string
  activeWindowIdQueue: ReadonlyArray<string>
}

export const windowsInitialState: WindowsState = {
  activeWindowIdQueue: []
}

export const windowsCreators = {
  setActiveWindowId: createAction('SET_ACTIVE_WINDOW_ID', (action) => (windowId: string) =>
    action(windowId)),
  unsetActiveWindowId: createAction('UNSET_ACTIVE_WINDOW_ID', (action) => (windowId: string) =>
    action(windowId))
}

export const windowsReducer = createReducer<WindowsState, ActionType<typeof windowsCreators>>(
  windowsInitialState
)
  .handleAction(windowsCreators.setActiveWindowId, (state, {payload: windowId}) => {
    const activeWindowIdQueue = [
      ...state.activeWindowIdQueue.filter((x) => x !== windowId),
      windowId
    ]
    return {
      activeWindowId: activeWindowIdQueue[activeWindowIdQueue.length - 1],
      activeWindowIdQueue
    }
  })
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:31,代码来源:windows.ts

示例6: createAction

import { createAction } from 'typesafe-actions';
import cuid from 'cuid';

import {
  ADD_TODO, TOGGLE_TODO, CHANGE_FILTER,
  ITodosFilter,
} from './types';

export const addTodo = createAction(ADD_TODO,
  (title: string) => ({
    type: ADD_TODO,
    payload: {
      id: cuid(),
      title: title,
      completed: false,
    },
  })
);

export const toggleTodo = createAction(TOGGLE_TODO,
  (id: string) => ({ type: TOGGLE_TODO, payload: id })
);

export const changeFilter = createAction(CHANGE_FILTER,
  (filter: ITodosFilter) => ({ type: CHANGE_FILTER, payload: filter })
);
开发者ID:vin1992,项目名称:react-redux-typescript-guide,代码行数:26,代码来源:actions.ts

示例7: Map

import {ActionType, createAction, createReducer, getType} from 'typesafe-actions'

import deleteFromMap from '../../../utils/deleteFromMap'

export interface ListsState {
  highlightedIndices: Map<number, number>
  itemCounts: Map<number, number>
}

export const listsInitialState: ListsState = {
  highlightedIndices: new Map(),
  itemCounts: new Map()
}

export const listsCreators = {
  removeList: createAction('REMOVE_LIST', (action) => (listIndex: number) => action({listIndex})),
  resetLists: createAction('RESET_LISTS'),
  setHighlightedIndex: createAction(
    'SET_HIGHLIGHTED_INDEX',
    (action) => (listIndex: number, itemIndex: number) => action({listIndex, itemIndex})
  ),
  setItemCount: createAction('SET_ITEM_COUNT', (action) => (listIndex: number, itemCount: number) =>
    action({listIndex, itemCount})),
  unsetHighlightedIndex: createAction(
    'UNSET_HIGHLIGHTED_INDEX',
    (action) => (listIndex: number, itemIndex: number) => action({listIndex, itemIndex})
  )
}

export const listsReducer = createReducer<ListsState, ActionType<typeof listsCreators>>(
  listsInitialState,
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:31,代码来源:lists.ts


注:本文中的typesafe-actions.createAction函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。