all repos — kōi @ b5de4391b4e6ac6d03170feb4108ea1b84312528

Minimalist task manager

src/lib/store/tasks.ts (view raw)

 1import { writable } from 'svelte/store';
 2import { v4 as uuidv4 } from 'uuid';
 3
 4let { update, set, subscribe } = writable<Task[]>([]);
 5
 6const addTask = (taskInput: Omit<Task, 'id'>) =>
 7	update((tasks) => {
 8		const task = { ...taskInput, id: uuidv4() };
 9		return [...tasks, task];
10	});
11
12export default { update, set, subscribe, addTask };