~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/knotless

git that lives in your Atmosphere account

Forked from chadtmiller.com/knotless

0
0
18 lines · 548 B Raw History
// Writing from a page, as whoever is logged in to it: the write, then the
// page's answers asked again, so it shows what was written.

import { invalidateAll } from '$app/navigation';

/**
 * Runs `write`, then has the page ask its answers again: nothing once
 * done, or why it failed, in the server's words.
 */
export async function written(write: () => Promise<unknown>): Promise<string | undefined> {
	try {
		await write();
	} catch (e) {
		return e instanceof Error ? e.message : String(e);
	}
	await invalidateAll();
	return undefined;
}