aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/handler.ts
blob: 03795ad94209ff6e1448e3232ea1c069bdabaea9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { goto } from "$app/navigation";
import { applyAction } from "$app/forms";

export default (submitting) =>
  () => {
    submitting = true;
    return async ({ result }) => {
      if (result.type === "redirect") {
        goto(result.location);
      } else {
        await applyAction(result);
      }
    };
  };