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 };