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


TypeScript Module.createAction方法代码示例

本文整理汇总了TypeScript中redux-typed-modules.Module.createAction方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Module.createAction方法的具体用法?TypeScript Module.createAction怎么用?TypeScript Module.createAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redux-typed-modules.Module的用法示例。


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

示例1: Module

    outputItems: [],
    name: null,
    message: null,
    itemCount: undefined,
    count: 0,
  };
};

const module = new Module({
  initialState: initialState(),
  actionExtraData: () => ({ when: new Date() }),
});

export const setJobType = module.createAction({
  type: 'crafting/job/set-job',
  action: (jobType: string) => ({ jobType }),
  reducer: (s, a) => ({ type: a.jobType }),
});

export const setStatus = module.createAction({
  type: 'crafting/job/set-status',
  action: (status: string) => ({ status }),
  reducer: (s, a) => ({ status: a.status }),
});

export const setCount = module.createAction({
  type: 'crafting/job/set-count',
  action: (count: number) => ({ count }),
  reducer: (s, a) => ({ count: a.count || 0 }),
});
开发者ID:Mehuge,项目名称:Camelot-Unchained,代码行数:30,代码来源:job.ts

示例2: initialize

    const screen: Size = { width: window.innerWidth, height: window.innerHeight };
    return {
      ...state,
      lastScreenSize: screen,
    };
  },
});

/////////////////////////////////
// Actions
/////////////////////////////////

// NO OP -- #TODO: do I really need this?
const init = module.createAction({
  type: 'layout/INITIALIZE',
  action: () => null,
  reducer: s => s,
});

// Async init - allows window onresize to dispatch actions
export function initialize() {
  return (dispatch: (action: any) => any) => {
    dispatch(init());
    window.onresize = () => {
      if (window.innerWidth >= 640 && window.innerHeight >= 480) {
        dispatch(resize());
      }
    };

    // hook up to event triggers
    game.on('navigate', (name: string) => {
开发者ID:Mehuge,项目名称:Camelot-Unchained,代码行数:31,代码来源:layout.ts

示例3: getInitialState

  SET_FILTER_BUTTONS: 'charactersheets-inventory-SET_FILTER_BUTTONS',
};

export interface FilterButtonState {
  filterButtons: InventoryFilterButton[];
}

export function getInitialState() {
  const initialState: FilterButtonState = {
    filterButtons: defaultFilterButtonIcons,
  };
  return initialState;
}

export const module = new Module({
  initialState: getInitialState(),
});

export const setFilterButtons = module.createAction({
  type: types.SET_FILTER_BUTTONS,
  action: (action: { filterButtons: InventoryFilterButton[] }) => action,
  reducer: (state, action) => {
    const filterButtons = action.filterButtons;
    return {
      filterButtons,
    };
  },
});

export default module.createReducer();
开发者ID:Mehuge,项目名称:Camelot-Unchained,代码行数:30,代码来源:filterButtonState.ts

示例4: get

// Initialize patcher signalr connections
export const initialize = module.createAction({
  type: 'controller/initialize',
  action: () => {
    Object.defineProperty(client, 'accessToken', { get() { return patcher.getAccessToken(); } });
    return (dispatch: (action: ControllerAction) => any) => {
      dispatch(reset() as ControllerAction);
      dispatch(initSignalR() as ControllerAction);
      registerPatcherHubEvents(dispatch);
      dispatch(getChannels());
      // update channel info on a timer...
      if (channelUpdateInterval === null) {
        channelUpdateInterval = setInterval(() => dispatch(getChannels()), 500);
      }

      try {
        // Connect to patcher api server signalr patcher hub
        startPatcherSignalR(dispatch).then((ok) => {
          if (ok) {
            // Connect to other server's signalr pathcer hubs.
            startOtherSignalR(dispatch);
          }
        });
      } catch (e) {
        console.error(e);
        dispatch(initSignalRFailed() as ControllerAction);
      }
    };
  },
});
开发者ID:codecorsair,项目名称:Camelot-Unchained,代码行数:30,代码来源:controller.ts

示例5: Module

  };
  return initialState;
}

export const module = new Module({
  initialState: getInitialState(),
});

export const onSelectBane = module.createAction({
  type: 'cu-character-creation/banes-and-boons/ON_SELECT_BANE',
  action: (action: { bane: BanesAndBoonsInfo }) => action,
  reducer: (state, action) => {
    const addedBanes = state.addedBanes;
    const traits = state.traits;
    addedBanes[action.bane.id] = action.bane.id;
    traits[action.bane.id] = { ...action.bane, selected: true };
    return {
      traits,
      addedBanes,
      totalPoints: state.totalPoints + action.bane.points,
    };
  },
});

export const onSelectBoon = module.createAction({
  type: 'cu-character-creation/banes-and-boons/ON_SELECT_BOON',
  action: (action: { boon: BanesAndBoonsInfo }) => action,
  reducer: (state, action) => {
    const addedBoons = state.addedBoons;
    const traits = state.traits;
    addedBoons[action.boon.id] = action.boon.id;
开发者ID:JoelTerMeer,项目名称:Camelot-Unchained,代码行数:31,代码来源:banesAndBoons.ts

示例6: getInitialState

  stack?: InventoryItem.Fragment[];
}

export interface InventoryState {
  itemSlots: ItemSlot[];
}

export function getInitialState() {
  const initialState: InventoryState = {
    itemSlots: [],
  };
  return initialState;
}

export const module = new Module({
  initialState: getInitialState(),
});

export const setItemSlots = module.createAction({
  type: types.SET_ITEM_SLOTS,
  action: (action: { itemSlots: ItemSlot[] }) => action,
  reducer: (state, action) => {
    const { itemSlots } = action;
    return {
      itemSlots,
    };
  },
});

export default module.createReducer();
开发者ID:Mehuge,项目名称:Camelot-Unchained,代码行数:30,代码来源:inventoryState.ts

示例7: initialize

    const screen: Size = { width: window.innerWidth, height: window.innerHeight };
    return {
      ...state,
      lastScreenSize: screen
    }
  }
});

/////////////////////////////////
// Actions
/////////////////////////////////

// NO OP -- #TODO: do I really need this?
const init = module.createAction({
  type: 'layout/INITIALIZE',
  action: () => null,
  reducer: s => s
});

// Async init - allows window onresize to dispatch actions
export function initialize() {
  return (dispatch: (action: any) => any) => {
    dispatch(init());
    window.onresize = () => {
      if (window.innerWidth >= 640 && window.innerHeight >= 480) {
        dispatch(resize());
      }
    };
  }
}
开发者ID:Shane7,项目名称:Camelot-Unchained,代码行数:30,代码来源:layout.ts

示例8: switch

  });
}

export const gotVoxRecipes = module.createAction({
  type: 'crafting/recipes/got-recipes',
  action: (recipeType: string, recipes: VoxRecipe[]) => ({
    recipeType,
    recipes,
  }),
  reducer: (s, a) => {
    const type = a.recipeType;
    switch (type) {
      case 'grind':
      case 'shape':
      case 'block':
      case 'make':
        const mappedVoxRecipes = mapVoxRecipesToRecipes(a.recipes);
        return { [type]: mappedVoxRecipes.sort((a, b) => a.name.localeCompare(b.name)) };
      case 'purify': {
        const mappedPurifyRecipes = mapPurifyRecipesToRecipes(a.recipes);
        return { [type]: mappedPurifyRecipes.sort((a, b) => a.name.localeCompare(b.name)) };
      }
    }
    console.error('CRAFTING: illegal recipe type ' + type);

    return {};
  },
});

export default module.createReducer();
开发者ID:Mehuge,项目名称:Camelot-Unchained,代码行数:30,代码来源:recipes.ts

示例9: Module

};

const module = new Module({
  initialState: initialState(),
  actionExtraData: () => {
    return {
      when: new Date(),
    };
  },
});

export const setUIMode = module.createAction({
  type: 'crafting/ui/mode',
  action: (mode: string) => {
    return { mode };
  },
  reducer: (s, a) => {
    return { mode: a.mode };
  },
});

export const setRemaining = module.createAction({
  type: 'crafting/ui/crafting-progress',
  action: (remaining: number) => {
    return { remaining };
  },
  reducer: (s, a) => {
    return { remaining: a.remaining };
  },
});
开发者ID:Mehuge,项目名称:Camelot-Unchained,代码行数:30,代码来源:ui.ts

示例10: initialize

    const screen: Size = { width: window.innerWidth, height: window.innerHeight };
    return {
      ...state,
      lastScreenSize: screen,
    };
  },
});

/////////////////////////////////
// Actions
/////////////////////////////////

// NO OP -- #TODO: do I really need this?
const init = module.createAction({
  type: 'layout/INITIALIZE',
  action: () => null,
  reducer: s => s,
});

// Async init - allows window onresize to dispatch actions
export function initialize() {
  return (dispatch: (action: any) => any) => {
    dispatch(init());
    window.onresize = () => {
      if (window.innerWidth >= 640 && window.innerHeight >= 480) {
        // dispatch(resize());
      }
    };

    // hook up to event triggers
    events.on('hudnav--navigate', (name: string) => {
开发者ID:JoelTerMeer,项目名称:Camelot-Unchained,代码行数:31,代码来源:layout.ts


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