apply_action: async()

in kit/svelteKitCustomClient/client.js [1441:1488]


		apply_action: async (result) => {
			if (result.type === "error") {
				const url = new URL(location.href);

				const { branch, route } = current;
				if (!route) return;

				const error_load = await load_nearest_error_page(
					current.branch.length,
					branch,
					route.errors
				);
				if (error_load) {
					const navigation_result = await get_navigation_result_from_branch({
						url,
						params: current.params,
						branch: branch.slice(0, error_load.idx).concat(error_load.node),
						status: result.status ?? 500,
						error: result.error,
						route,
					});

					current = navigation_result.state;

					root.$set(navigation_result.props);

					tick().then(reset_focus);
				}
			} else if (result.type === "redirect") {
				goto(result.location, { invalidateAll: true }, []);
			} else {
				/** @type {Record<string, any>} */
				root.$set({
					// this brings Svelte's view of the world in line with SvelteKit's
					// after use:enhance reset the form....
					form: null,
					page: { ...page, form: result.data, status: result.status },
				});

				// ...so that setting the `form` prop takes effect and isn't ignored
				await tick();
				root.$set({ form: result.data });

				if (result.type === "success") {
					reset_focus();
				}
			}
		},