diff options
Diffstat (limited to 'client/src/lib/data/links.ts')
| -rw-r--r-- | client/src/lib/data/links.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/client/src/lib/data/links.ts b/client/src/lib/data/links.ts new file mode 100644 index 0000000..0f0a9ce --- /dev/null +++ b/client/src/lib/data/links.ts @@ -0,0 +1,18 @@ +import type { ShortenRequest } from "$lib/actions/shorten"; +import type { Writable } from "svelte/store"; +import { writable } from "svelte/store"; + +function createLinks() { + const { subscribe, update }: Writable<ShortenRequest[]> = writable([]); + + function add(request: ShortenRequest) { + update((l) => [request, ...l.slice(0, 2)]); + } + + return { + subscribe, + add, + }; +} + +export const links = createLinks(); |
