import { Sinks , Sources } from './types' ; import { Todo , Uid } from '../../domain/model' ; import { findIndex , remove } from '167' ; import { sample } from '@most/sample' ; export function RemoveTodo ( sinks ) { const { removeTodo$ , todos$ } = sinks ; const updatedTodos$ = sample ( removeTodo , removeTodo$ , todos$ ) ; return { todos$ : updatedTodos$ } ; } function removeTodo ( todoId , todos ) { const index = findIndex ( ( { id } ) => id === todoId , todos ) ; return remove ( index , 1 , todos ) ; }