• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript typesafe-actions.createAsyncAction函数代码示例发布时间:2022-05-25
下一篇:
TypeScript typesafe-actions.action函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap