import { Sinks , Sources } from './types' ; import { map , sampleWith } from 'most' ; import { Todo } from '../../domain/model' ; import { filter } from '167' ; export function ClearCompleted ( sinks ) { const { clearCompletedTodos$ , todos$ } = sinks ; const updatedTodos$ = map ( clearCompleted , sampleWith ( clearCompletedTodos$ , todos$ ) ) ; return { todos$ : updatedTodos$ } ; } function clearCompleted ( todos ) { return filter ( ( todo ) => ! todo . completed , todos ) ; }