adding a redux todo list to playground

This commit is contained in:
Ken
2019-01-24 12:56:23 -08:00
parent 8b0a0f7569
commit a61d89ea14
12 changed files with 212 additions and 16 deletions

View File

@@ -0,0 +1,15 @@
import { Action, ActionCreator } from 'redux';
export type ActionTypes = 'add' | 'remove' | 'edit' | 'complete' | 'completeAll' | 'clear' | 'filter';
type TodoActionCreator = ActionCreator<Action<ActionTypes>>;
export interface TodoAction extends Action<ActionTypes> {
[extraProps: string]: any;
}
export const add = (label: string): TodoAction => ({ type: 'add', label });
export const remove = (id: string): TodoAction => ({ type: 'remove', id });
export const edit = (id: string, label: string): TodoAction => ({ type: 'edit', id, label });
export const complete = (id: string): TodoAction => ({ type: 'complete', id });
export const completeAll = (): TodoAction => ({ type: 'completeAll' });
export const clear = (): TodoAction => ({ type: 'clear' });
export const filter = (filterTypes: string): TodoAction => ({ type: 'filter', filterTypes });