import { dispatch , effect , state } from "./model" ; const randomId = ( ) => Math . random ( ) . toString ( ) ; export const newTodo = ( text ) => { const id = effect ( randomId ) ( ) ; state . todos [ id ] = { text , done : false , } ; } ; export const toggle = ( id ) => { state . todos [ id ] . done = ! state . todos [ id ] . done ; } ; export const deleteItem = ( id ) => { delete state . todos [ id ] ; } ; export const deleteAll = ( ) => { Object . keys ( state . todos ) . forEach ( id => { dispatch ( deleteItem ) ( id ) ; } ) ; } ;