本文整理匯總了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);
}
};