about summary refs log tree commit diff
path: root/client/src/data/links.ts
blob: 3ccf100c6f15dbee6c86a2375a0610ca3c1ca5e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import type { ShortenRequest } from "$actions/shorten";
import { Writable, 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();