11import  {  Derived ,  Store ,  batch  }  from  '@tanstack/store' 
2- 
2+ import   {   throttle   }   from   '@tanstack/pacer' 
33import  { 
44  deleteBy , 
55  determineFormLevelErrorSourceAndValue , 
@@ -22,11 +22,6 @@ import {
2222}  from  './standardSchemaValidator' 
2323import  {  defaultFieldMeta ,  metaHelper  }  from  './metaHelper' 
2424import  {  formEventClient  }  from  './EventClient' 
25- import  type  { 
26-   RequestFormForceReset , 
27-   RequestFormReset , 
28-   RequestFormState , 
29- }  from  './EventClient' 
3025import  type  {  ValidationLogicFn  }  from  './ValidationLogic' 
3126import  type  { 
3227  StandardSchemaV1 , 
@@ -1297,17 +1292,26 @@ export class FormApi<
12971292
12981293    this . update ( opts  ||  { } ) 
12991294
1295+     const  debouncedDevtoolState  =  throttle ( 
1296+       ( state : AnyFormState )  => 
1297+         formEventClient . emit ( 'form-state' ,  { 
1298+           id : this . _formId , 
1299+           state : state , 
1300+         } ) , 
1301+       { 
1302+         wait : 300 , 
1303+       } , 
1304+     ) 
1305+ 
1306+     // devtool broadcasts 
13001307    this . store . subscribe ( ( )  =>  { 
1301-       formEventClient . emit ( 'form-state-change' ,  { 
1302-         id : this . _formId , 
1303-         state : this . store . state , 
1304-         options : this . options , 
1305-       } ) 
1308+       debouncedDevtoolState ( this . store . state ) 
13061309    } ) 
13071310
1311+     // devtool requests 
13081312    formEventClient . on ( 'request-form-state' ,  ( e )  =>  { 
13091313      if  ( e . payload . id  ===  this . _formId )  { 
1310-         formEventClient . emit ( 'form-state-change ' ,  { 
1314+         formEventClient . emit ( 'form-api ' ,  { 
13111315          id : this . _formId , 
13121316          state : this . store . state , 
13131317          options : this . options , 
@@ -1377,7 +1381,7 @@ export class FormApi<
13771381    const  {  onMount }  =  this . options . validators  ||  { } 
13781382
13791383    // broadcast form state for devtools on mounting 
1380-     formEventClient . emit ( 'form-state-change ' ,  { 
1384+     formEventClient . emit ( 'form-api ' ,  { 
13811385      id : this . _formId , 
13821386      state : this . store . state , 
13831387      options : this . options , 
@@ -1455,6 +1459,12 @@ export class FormApi<
14551459        ) , 
14561460      ) 
14571461    } ) 
1462+ 
1463+     formEventClient . emit ( 'form-api' ,  { 
1464+       id : this . _formId , 
1465+       state : this . store . state , 
1466+       options : this . options , 
1467+     } ) 
14581468  } 
14591469
14601470  /** 
@@ -2053,7 +2063,7 @@ export class FormApi<
20532063        meta : submitMetaArg , 
20542064      } ) 
20552065
2056-       formEventClient . emit ( 'form-submission-state-change ' ,  { 
2066+       formEventClient . emit ( 'form-submission' ,  { 
20572067        id : this . _formId , 
20582068        submissionAttempt : this . state . submissionAttempts , 
20592069        successful : false , 
@@ -2077,7 +2087,7 @@ export class FormApi<
20772087        meta : submitMetaArg , 
20782088      } ) 
20792089
2080-       formEventClient . emit ( 'form-submission-state-change ' ,  { 
2090+       formEventClient . emit ( 'form-submission' ,  { 
20812091        id : this . _formId , 
20822092        submissionAttempt : this . state . submissionAttempts , 
20832093        successful : false , 
@@ -2116,7 +2126,7 @@ export class FormApi<
21162126          isSubmitSuccessful : true ,  // Set isSubmitSuccessful to true on successful submission 
21172127        } ) ) 
21182128
2119-         formEventClient . emit ( 'form-submission-state-change ' ,  { 
2129+         formEventClient . emit ( 'form-submission' ,  { 
21202130          id : this . _formId , 
21212131          submissionAttempt : this . state . submissionAttempts , 
21222132          successful : true , 
@@ -2130,7 +2140,7 @@ export class FormApi<
21302140        isSubmitSuccessful : false ,  // Ensure isSubmitSuccessful is false if an error occurs 
21312141      } ) ) 
21322142
2133-       formEventClient . emit ( 'form-submission-state-change ' ,  { 
2143+       formEventClient . emit ( 'form-submission' ,  { 
21342144        id : this . _formId , 
21352145        submissionAttempt : this . state . submissionAttempts , 
21362146        successful : false , 
0 commit comments