本文整理汇总了TypeScript中typesafe-actions.getType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getType函数的具体用法?TypeScript getType怎么用?TypeScript getType使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getType函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: watchCreateAndRemoveLastPosition
// use channel to make sure every create/remove run one by one
function* watchCreateAndRemoveLastPosition(): SagaIterator {
try {
const createLastPositionChan: TakeableChannel<{}> = yield actionChannel(
getType(lastPositionsCreator.createLastPosition)
)
const removeLastPositionChan: TakeableChannel<{}> = yield actionChannel(
getType(lastPositionsCreator.removeLastPosition)
)
while (true) {
const [createLastPositionAction, removeLastPositionAction]: [
ReturnType<typeof lastPositionsCreator.createLastPosition> | void,
ReturnType<typeof lastPositionsCreator.removeLastPosition> | void
] = yield race([take(createLastPositionChan), take(removeLastPositionChan)])
if (createLastPositionAction) {
yield call(createLastPosition, createLastPositionAction)
}
if (removeLastPositionAction) {
yield call(removeLastPosition, removeLastPositionAction)
}
}
} catch (err) {
console.error(err)
}
}
示例2: switch
const subtitle: Middleware<{}, RootState> = store => next => action => {
switch (action.type) {
case getType(subtitleActions.addSubtitle):
case getType(subtitleActions.updateSubtitle):
case getType(subtitleActions.deleteSubtitle):
next(action);
const sorted = store
.getState()
.subtitle.data.slice(0)
.sort((a, b) => {
if (a.startTime > b.startTime) {
return 1;
} else if (a.startTime < b.startTime) {
return -1;
} else {
return 0;
}
});
store.dispatch(subtitleActions.sortSubtitle(sorted));
// TODO: Update selectedIndex
return;
default:
return next(action);
}
};
示例3: switch
const handleChange: HandleFormChange<TradeState['form']> = (key) => (state = null, action) => {
switch (action.type) {
case getType(tradeFormChange):
return action.payload.field === key ? action.payload.value : state
case getType(placeTradeAction.success):
return null
default: return state
}
}
示例4: switch
reduxCounter: (state = 0, action) => {
switch (action.type) {
case getType(countersActions.increment):
return state + 1; // action is type: { type: "INCREMENT"; }
case getType(countersActions.add):
return state + action.payload; // action is type: { type: "ADD"; payload: number; }
default:
return state;
}
},
示例5: switch
export const settings: Reducer<Settings, SettingsAction> = (
state: Settings = initialState,
action: SettingsAction
) => {
switch (action.type) {
case getType(actions.loaded):
return {
...state,
...action.payload,
farming: {
...state.farming,
...action.payload.farming
}
};
case getType(actions.toggleCollapsedSection):
return {
...state,
collapsedSections: {
...state.collapsedSections,
[action.payload]: !state.collapsedSections[action.payload]
}
};
case getType(actions.setSetting):
if (state[action.payload.property] !== action.payload.value) {
return {
...state,
[action.payload.property]: action.payload.value
};
} else {
return state;
}
case getType(actions.setCharacterOrder):
const order = action.payload;
return {
...state,
// Remove these characters from the list and add them, in the new sort order,
// to the end of the list
customCharacterSort: state.customCharacterSort
.filter((id) => !order.includes(id))
.concat(order)
};
default:
return state;
}
};
示例6: switch
const handleDepthUpdate = (direction: Direction): MyReducer<OrderType[]> => (state = [], action) => {
switch (action.type) {
case getType(getDepthAction.success):
return action.payload.direction === direction ? action.payload.orders : state
default: return state
}
}
示例7: switch
const fileHandler: Middleware<{}, RootState> = store => next => action => {
switch (action.type) {
case getType(subtitleActions.newData):
case getType(subtitleActions.loadData):
store.dispatch(welcomeActions.setSubtitleReady(true));
return next(action);
case getType(playerActions.loadVideo):
store.dispatch(welcomeActions.setVideoReady(true));
return next(action);
case getType(subtitleActions.saveData):
const { filepath, data } = action.payload;
ipcRenderer.send('request-save-subtitle', filepath, data);
return next(action);
default:
return next(action);
}
};