aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/handler.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/handler.ts')
-rw-r--r--src/lib/handler.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/handler.ts b/src/lib/handler.ts
new file mode 100644
index 00000000..baca442d
--- /dev/null
+++ b/src/lib/handler.ts
@@ -0,0 +1,13 @@
+import { goto } from "$app/navigation";
+import { applyAction } from "$app/forms";
+
+export default (toggle) => () => {
+ toggle();
+ return async ({ result }) => {
+ if (result.type === "redirect") {
+ goto(result.location);
+ } else {
+ await applyAction(result);
+ }
+ };
+};