File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -596,6 +596,10 @@ export type StoreListenerStats = {
596596 * The number of InvalidCellListeners registered with the Store.
597597 */
598598 invalidCell ?: number ;
599+ /**
600+ * The number of TransactionListeners registered with the Store.
601+ */
602+ transaction ?: number ;
599603} ;
600604
601605/**
Original file line number Diff line number Diff line change @@ -965,6 +965,7 @@ export const createStore: typeof createStoreDecl = (): Store => {
965965 cellIds : collPairSize ( cellIdsListeners , collSize3 ) ,
966966 cell : collPairSize ( cellListeners , collSize4 ) ,
967967 invalidCell : collPairSize ( invalidCellListeners , collSize4 ) ,
968+ transaction : collPairSize ( finishTransactionListeners ) ,
968969 }
969970 : { } ;
970971
Original file line number Diff line number Diff line change @@ -694,6 +694,7 @@ describe('Stats', () => {
694694 cellIds : 0 ,
695695 cell : 0 ,
696696 invalidCell : 0 ,
697+ transaction : 0 ,
697698 } ;
698699 } ) ;
699700
@@ -723,5 +724,20 @@ describe('Stats', () => {
723724 expectedListenerStats [ thing ] = 0 ;
724725 expect ( store . getListenerStats ( ) ) . toEqual ( expectedListenerStats ) ;
725726 } ) ;
727+ test . each ( [ [ 'willFinishTransaction' ] , [ 'didFinishTransaction' ] ] ) (
728+ '%s' ,
729+ ( thing ) => {
730+ const addListener =
731+ 'add' + thing [ 0 ] . toUpperCase ( ) + thing . substr ( 1 ) + 'Listener' ;
732+ expect ( ( ( store as any ) [ addListener ] as any ) ( ( ) : null => null ) ) . toEqual (
733+ '0' ,
734+ ) ;
735+ expectedListenerStats . transaction = 1 ;
736+ expect ( store . getListenerStats ( ) ) . toEqual ( expectedListenerStats ) ;
737+ store . delListener ( '0' ) ;
738+ expectedListenerStats . transaction = 0 ;
739+ expect ( store . getListenerStats ( ) ) . toEqual ( expectedListenerStats ) ;
740+ } ,
741+ ) ;
726742 } ) ;
727743} ) ;
You can’t perform that action at this time.
0 commit comments