Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

inject-form.ts

14 lines471 Bytes

1import { FormApi } from '@tanstack/form-core'
2import { injectStore } from '@tanstack/angular-store'
3import type { FormOptions, Validator } from '@tanstack/form-core'
4​
5export function injectForm<
6 TFormData,
7 TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,
8>(opts?: FormOptions<TFormData, TFormValidator>) {
9 const api = new FormApi<TFormData, TFormValidator>(opts)
10​
11 injectStore(api.store, (state) => state.isSubmitting)
12​
13 return api