mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
no complete all
This commit is contained in:
@@ -13,7 +13,6 @@ export const actions = {
|
||||
remove: (id: string) => action('remove', { id }),
|
||||
edit: (id: string, label: string) => action('edit', { id, label }),
|
||||
complete: (id: string) => action('complete', { id }),
|
||||
completeAll: () => action('completeAll'),
|
||||
clear: () => action('clear'),
|
||||
filter: (filterTypes: string) => action('filter', { filter: filterTypes })
|
||||
};
|
||||
|
||||
@@ -16,7 +16,6 @@ export function mapDispatchToProps(dispatch: Dispatch<TodoAction>) {
|
||||
add: (label: string) => dispatch(actions.add(label)),
|
||||
remove: (id: string) => dispatch(actions.remove(id)),
|
||||
complete: (id: string) => dispatch(actions.complete(id)),
|
||||
completeAll: () => dispatch(actions.completeAll()),
|
||||
edit: (id: string, label: string) => dispatch(actions.edit(id, label)),
|
||||
clear: () => dispatch(actions.clear()),
|
||||
setFilter: (filter: FilterTypes) => dispatch(actions.filter(filter))
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Reducer } from 'redux';
|
||||
import { ActionTypes, TodoAction, TodoActionLookup } from '../actions';
|
||||
import { Draft, produce } from 'immer';
|
||||
|
||||
export type ImmerReducer<T, A = any> = (state: Draft<T>, action: A) => T;
|
||||
export type ImmerReducer<T, A = any> = (state: Draft<T>, action?: A) => T;
|
||||
export type HandlerMap<T> = { [actionType in ActionTypes]?: ImmerReducer<T, TodoActionLookup[actionType]> };
|
||||
|
||||
function isHandlerFunction<T>(handlerOrMap: HandlerMap<T> | ImmerReducer<T>): handlerOrMap is ImmerReducer<T> {
|
||||
|
||||
@@ -24,7 +24,7 @@ export const reducer = combineReducers<Store>({
|
||||
return draft;
|
||||
},
|
||||
|
||||
clear(draft, action) {
|
||||
clear(draft) {
|
||||
Object.keys(draft).forEach(id => {
|
||||
if (draft[id].completed) {
|
||||
delete draft[id];
|
||||
|
||||
Reference in New Issue
Block a user