@@ -19,6 +19,7 @@ import {
19
19
StoreValue ,
20
20
Meta ,
21
21
InternalFieldData ,
22
+ ValuedNotifyInfo ,
22
23
} from './interface' ;
23
24
import { HOOK_MARK } from './FieldContext' ;
24
25
import { allPromiseFinish } from './utils/asyncUtil' ;
@@ -134,9 +135,14 @@ export class FormStore {
134
135
this . validateMessages = validateMessages ;
135
136
} ;
136
137
138
+ // ========================== Dev Warning =========================
139
+ private timeoutId : number = null ;
140
+
137
141
private warningUnhooked = ( ) => {
138
- if ( process . env . NODE_ENV !== 'production' ) {
139
- setTimeout ( ( ) => {
142
+ if ( process . env . NODE_ENV !== 'production' && ! this . timeoutId ) {
143
+ this . timeoutId = window . setTimeout ( ( ) => {
144
+ this . timeoutId = null ;
145
+
140
146
if ( ! this . formHooked ) {
141
147
warning (
142
148
false ,
@@ -441,8 +447,13 @@ export class FormStore {
441
447
} ) ;
442
448
} ;
443
449
444
- private getFields = ( ) : InternalFieldData [ ] =>
445
- this . getFieldEntities ( true ) . map (
450
+ private getFields = ( ) : InternalFieldData [ ] => {
451
+ console . time ( 'getFieldEntities' ) ;
452
+ const entities = this . getFieldEntities ( true ) ;
453
+ console . timeEnd ( 'getFieldEntities' ) ;
454
+
455
+ console . time ( 'map fields' ) ;
456
+ const fields = entities . map (
446
457
( field : FieldEntity ) : InternalFieldData => {
447
458
const namePath = field . getNamePath ( ) ;
448
459
const meta = field . getMeta ( ) ;
@@ -459,6 +470,10 @@ export class FormStore {
459
470
return fieldData ;
460
471
} ,
461
472
) ;
473
+ console . timeEnd ( 'map fields' ) ;
474
+
475
+ return fields ;
476
+ } ;
462
477
463
478
// =========================== Observer ===========================
464
479
private registerField = ( entity : FieldEntity ) => {
@@ -503,9 +518,15 @@ export class FormStore {
503
518
info : NotifyInfo ,
504
519
) => {
505
520
if ( this . subscribable ) {
521
+ const mergedInfo : ValuedNotifyInfo = {
522
+ ...info ,
523
+ store : this . getFieldsValue ( true ) ,
524
+ } ;
525
+ console . time ( `notify ${ info . type } ` ) ;
506
526
this . getFieldEntities ( ) . forEach ( ( { onStoreChange } ) => {
507
- onStoreChange ( prevStore , namePathList , info ) ;
527
+ onStoreChange ( prevStore , namePathList , mergedInfo ) ;
508
528
} ) ;
529
+ console . timeEnd ( `notify ${ info . type } ` ) ;
509
530
} else {
510
531
this . forceRootUpdate ( ) ;
511
532
}
@@ -605,7 +626,9 @@ export class FormStore {
605
626
const { onFieldsChange } = this . callbacks ;
606
627
607
628
if ( onFieldsChange ) {
629
+ console . time ( 'getFields' ) ;
608
630
const fields = this . getFields ( ) ;
631
+ console . timeEnd ( 'getFields' ) ;
609
632
610
633
/**
611
634
* Fill errors since `fields` may be replaced by controlled fields
0 commit comments