aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/handler.js
blob: 05e484ecc8120fdc8b96ad6d0297cb74d6a07d49 (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) =>
  ({ formElement, formData, action, cancel }) => {
    submitting = true;
    return async ({ result }) => {
      if (result.type === "redirect") {
        goto(result.location);
      } else {
        await applyAction(result);
      }
    };
  };