本文整理匯總了TypeScript中redux-typed.isActionType函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isActionType函數的具體用法?TypeScript isActionType怎麽用?TypeScript isActionType使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isActionType函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: if
export const reducer: Reducer<GenreDetailsState> = (state, action) => {
if (isActionType(action, RequestGenreDetails)) {
return { requestedGenreId: action.genreId, albums: [], isLoaded: false };
} else if (isActionType(action, ReceiveGenreDetails)) {
return { requestedGenreId: action.genreId, albums: action.albums, isLoaded: true };
} else {
return state || { requestedGenreId: null as number, albums: [], isLoaded: false };
}
};
示例2: if
export const reducer: Reducer<AlbumDetailsState> = (state, action) => {
if (isActionType(action, RequestAlbumDetails)) {
return { requestedAlbumId: action.albumId, album: null };
} else if (isActionType(action, ReceiveAlbumDetails)) {
return { requestedAlbumId: action.album.AlbumId, album: action.album };
} else {
return state || unloadedState;
}
};
示例3: if
export const reducer: Reducer<UsersState> = (state, action) => {
if (isActionType(action, UserLoad)) {
return { isLoading: true, users: state.users, user:state.user };
} else if (isActionType(action, UserList)) {
return {users: action.users, user:state.user, isLoading: false };
}else if (isActionType(action, UserItem)) {
return {users: state.users, user: action.user, isLoading: false };
}
return state || unloadedState;
};
示例4:
export const reducer: Reducer<DialogState> = (state, action) => {
if (isActionType(action, OpenDialog)) {
return { isOpen: true };
}
if (isActionType(action, CloseDialog)) {
return { isOpen: false };
}
// For unrecognized actions (or in cases where actions have no effect), must return the existing state
// (or default initial state if none was supplied)
return state || { isOpen: false };
};
示例5: if
export const reducer: Reducer<AddPollState> = (state, action) => {
if (isActionType(action, AddPoll)) {
return { success: null, isLoading: true, pollId: state.pollId };
} else if (isActionType(action, AddPollSuccess)) {
return { success: true, isLoading: false, pollId: action.details.id };
} else if (isActionType(action, AddPollFailure)) {
return { success: false, isLoading: false, pollId: 0 };
}
// For unrecognized actions (or in cases where actions have no effect), must return the existing state
// (or default initial state if none was supplied)
return state || unloadedState;
};
示例6: if
export const reducer: Reducer<WeatherForecastsState> = (state, action) => {
if (isActionType(action, RequestWeatherForecasts)) {
return { startDateIndex: action.startDateIndex, isLoading: true, forecasts: state.forecasts };
} else if (isActionType(action, ReceiveWeatherForecasts)) {
// Only accept the incoming data if it matches the most recent request. This ensures we correctly
// handle out-of-order responses.
if (action.startDateIndex === state.startDateIndex) {
return { startDateIndex: action.startDateIndex, forecasts: action.forecasts, isLoading: false };
}
}
// For unrecognized actions (or in cases where actions have no effect), must return the existing state
// (or default initial state if none was supplied)
return state || unloadedState;
};
示例7:
export const reducer: Reducer<GenresListState> = (state, action) => {
if (isActionType(action, ReceiveGenresList)) {
return { genres: action.genres, isLoaded: true };
} else {
return state || { genres: [], isLoaded: false };
}
};
示例8:
export const reducer: Reducer<FeaturedAlbumsState> = (state, action) => {
if (isActionType(action, ReceiveFeaturedAlbums)) {
return { albums: action.albums, isLoaded: true };
} else {
return state || { albums: [], isLoaded: false };
}
};
示例9:
export const reducer: Reducer<LocationState> = (state, action) => {
if (isActionType(action, RequestLocation)) {
return { name: action.location };
}
return state || { name: "" };
};
示例10:
export const reducer: Reducer<CounterState> = (state, action) => {
if (isActionType(action, IncrementCount)) {
return { count: state.count + 1 };
}
// For unrecognized actions (or in cases where actions have no effect), must return the existing state
// (or default initial state if none was supplied)
return state || { count: 0 };
};