File tree Expand file tree Collapse file tree 5 files changed +640
-43
lines changed
Expand file tree Collapse file tree 5 files changed +640
-43
lines changed Original file line number Diff line number Diff line change 5252 ],
5353 "dependencies" : {
5454 "@tanstack/devtools-event-client" : " ^0.3.5" ,
55- "@tanstack/pacer" : " ^0.15.3 " ,
55+ "@tanstack/pacer-lite " : " ^0.1.0 " ,
5656 "@tanstack/store" : " ^0.7.7"
5757 },
5858 "devDependencies" : {
Original file line number Diff line number Diff line change 11import { Derived , Store , batch } from '@tanstack/store'
2- import { throttle } from '@tanstack/pacer'
32import {
43 deleteBy ,
54 determineFormLevelErrorSourceAndValue ,
@@ -15,13 +14,15 @@ import {
1514 uuid ,
1615} from './utils'
1716import { defaultValidationLogic } from './ValidationLogic'
18-
1917import {
2018 isStandardSchemaValidator ,
2119 standardSchemaValidators ,
2220} from './standardSchemaValidator'
2321import { defaultFieldMeta , metaHelper } from './metaHelper'
2422import { formEventClient } from './EventClient'
23+ import { throttleFormState } from './throttles'
24+
25+ // types
2526import type { ValidationLogicFn } from './ValidationLogic'
2627import type {
2728 StandardSchemaV1 ,
@@ -1304,20 +1305,9 @@ export class FormApi<
13041305
13051306 this . update ( opts || { } )
13061307
1307- const debouncedDevtoolState = throttle (
1308- ( state : AnyFormState ) =>
1309- formEventClient . emit ( 'form-state' , {
1310- id : this . _formId ,
1311- state : state ,
1312- } ) ,
1313- {
1314- wait : 300 ,
1315- } ,
1316- )
1317-
13181308 // devtool broadcasts
13191309 this . store . subscribe ( ( ) => {
1320- debouncedDevtoolState ( this . store . state )
1310+ throttleFormState ( this )
13211311 } )
13221312
13231313 // devtool requests
Original file line number Diff line number Diff line change 1+ import { liteThrottle } from '@tanstack/pacer-lite'
2+ import { formEventClient } from './EventClient'
3+
4+ import type { AnyFormApi } from './FormApi'
5+
6+ export const throttleFormState = liteThrottle (
7+ ( form : AnyFormApi ) =>
8+ formEventClient . emit ( 'form-state' , {
9+ id : form . formId ,
10+ state : form . store . state ,
11+ } ) ,
12+ {
13+ wait : 300 ,
14+ } ,
15+ )
Original file line number Diff line number Diff line change 1- import { defaultValidationLogic } from './ValidationLogic'
21import type { ValidationLogicProps } from './ValidationLogic'
32import type { FieldValidators } from './FieldApi'
43import type { FormValidators } from './FormApi'
You can’t perform that action at this time.
0 commit comments