Skip to content

Commit 9160ae0

Browse files
committed
[tools] has* listeners & hooks
1 parent 410e1b1 commit 9160ae0

File tree

4 files changed

+407
-9
lines changed

4 files changed

+407
-9
lines changed

src/tools/api/core.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
CELL_IDS,
66
DEFAULT,
77
EMPTY_STRING,
8+
HAS,
89
IDS,
910
LISTENER,
1011
ROW,
@@ -111,24 +112,31 @@ export type SharedTableTypes = [
111112
tablesWhenSetType: string,
112113
tableIdType: string,
113114
cellIdType: string,
115+
hasTablesListenerType: string,
114116
tablesListenerType: string,
115117
tableIdsListenerType: string,
118+
hasTableListenerType: string,
116119
tableListenerType: string,
117120
tableCellIdsListenerType: string,
121+
hasTableCellListenerType: string,
118122
rowCountListenerType: string,
119123
rowIdsListenerType: string,
120124
sortedRowIdsListenerType: string,
125+
hasRowListenerType: string,
121126
rowListenerType: string,
122127
cellIdsListenerType: string,
128+
hasCellListenerType: string,
123129
cellListenerType: string,
124130
tablesTypes: IdMap<TableTypes>,
125131
];
126132
export type SharedValueTypes = [
127133
valuesType: string,
128134
valuesWhenSetType: string,
129135
valueIdType: string,
136+
hasValuesListenerType: string,
130137
valuesListenerType: string,
131138
valueIdsListenerType: string,
139+
hasValueListenerType: string,
132140
valueListenerType: string,
133141
];
134142

@@ -302,15 +310,20 @@ export const getStoreCoreApi = (
302310
rowCallbackType,
303311
tableCellCallbackType,
304312
tableCallbackType,
313+
hasTablesListenerType,
305314
tablesListenerType,
306315
tableIdsListenerType,
316+
hasTableListenerType,
307317
tableListenerType,
308318
tableCellIdsListenerType,
319+
hasTableCellListenerType,
309320
rowCountListenerType,
310321
rowIdsListenerType,
311322
sortedRowIdsListenerType,
323+
hasRowListenerType,
312324
rowListenerType,
313325
cellIdsListenerType,
326+
hasCellListenerType,
314327
cellListenerType,
315328
invalidCellListenerType,
316329
] = getTablesTypes(storeInstance, storeType);
@@ -395,15 +408,20 @@ export const getStoreCoreApi = (
395408
tableIdType,
396409
cellIdType,
397410
tableCallbackType,
411+
hasTablesListenerType,
398412
tablesListenerType,
399413
tableIdsListenerType,
414+
hasTableListenerType,
400415
tableListenerType,
401416
tableCellIdsListenerType,
417+
hasTableCellListenerType,
402418
rowCountListenerType,
403419
rowIdsListenerType,
404420
sortedRowIdsListenerType,
421+
hasRowListenerType,
405422
rowListenerType,
406423
cellIdsListenerType,
424+
hasCellListenerType,
407425
cellListenerType,
408426
invalidCellListenerType,
409427
);
@@ -413,15 +431,20 @@ export const getStoreCoreApi = (
413431
tablesWhenSetType,
414432
tableIdType,
415433
cellIdType,
434+
hasTablesListenerType,
416435
tablesListenerType,
417436
tableIdsListenerType,
437+
hasTableListenerType,
418438
tableListenerType,
419439
tableCellIdsListenerType,
440+
hasTableCellListenerType,
420441
rowCountListenerType,
421442
rowIdsListenerType,
422443
sortedRowIdsListenerType,
444+
hasRowListenerType,
423445
rowListenerType,
424446
cellIdsListenerType,
447+
hasCellListenerType,
425448
cellListenerType,
426449
tablesTypes,
427450
];
@@ -689,6 +712,13 @@ export const getStoreCoreApi = (
689712
'tables' + JSON,
690713
);
691714

715+
// addHasTablesListener
716+
addProxyListener(
717+
HAS + TABLES,
718+
hasTablesListenerType,
719+
getTheContentOfTheStoreDoc(1, 8, 0, 1) + ' changes',
720+
);
721+
692722
// addTablesListener
693723
addProxyListener(
694724
TABLES,
@@ -699,6 +729,15 @@ export const getStoreCoreApi = (
699729
// addTableIdsListener
700730
addProxyListener(TABLE_IDS, tableIdsListenerType, getListenerDoc(2, 0, 1));
701731

732+
// addHasTableListener
733+
addProxyListener(
734+
HAS + TABLE,
735+
hasTableListenerType,
736+
getListenerDoc(3, 0, 0, 1),
737+
`tableId: ${tableIdType} | null`,
738+
'tableId',
739+
);
740+
702741
// addTableListener
703742
addProxyListener(
704743
TABLE,
@@ -717,6 +756,20 @@ export const getStoreCoreApi = (
717756
'tableId',
718757
);
719758

759+
// addHasTableCellListener
760+
addProxyListener(
761+
HAS + TABLE + CELL,
762+
hasTableCellListenerType,
763+
getListenerDoc(16, 3, 0, 1),
764+
`tableId: ${tableIdType} | null, cellId: ${arrayJoin(
765+
mapTablesSchema(
766+
(tableId) => mapGet(tablesTypes, tableId)?.[4] ?? EMPTY_STRING,
767+
),
768+
' | ',
769+
)} | null`,
770+
'tableId, cellId',
771+
);
772+
720773
// addRowCountListener
721774
addProxyListener(
722775
ROW + COUNT,
@@ -752,6 +805,15 @@ export const getStoreCoreApi = (
752805
'<TId extends TableId>',
753806
);
754807

808+
// addHasRowListener
809+
addProxyListener(
810+
HAS + ROW,
811+
hasRowListenerType,
812+
getListenerDoc(5, 3, 0, 1),
813+
`tableId: ${tableIdType} | null, rowId: IdOrNull`,
814+
'tableId, rowId',
815+
);
816+
755817
// addRowListener
756818
addProxyListener(
757819
ROW,
@@ -770,6 +832,20 @@ export const getStoreCoreApi = (
770832
'tableId, rowId',
771833
);
772834

835+
// addHasCellListener
836+
addProxyListener(
837+
HAS + CELL,
838+
hasCellListenerType,
839+
getListenerDoc(7, 5, 0, 1),
840+
`tableId: ${tableIdType} | null, rowId: IdOrNull, cellId: ${arrayJoin(
841+
mapTablesSchema(
842+
(tableId) => mapGet(tablesTypes, tableId)?.[4] ?? EMPTY_STRING,
843+
),
844+
' | ',
845+
)} | null`,
846+
'tableId, rowId, cellId',
847+
);
848+
773849
// addCellListener
774850
addProxyListener(
775851
CELL,
@@ -835,8 +911,10 @@ export const getStoreCoreApi = (
835911
valueIdType,
836912
_valueType,
837913
valueCallbackType,
914+
hasValuesListenerType,
838915
valuesListenerType,
839916
valueIdsListenerType,
917+
hasValueListenerType,
840918
valueListenerType,
841919
invalidValueListenerType,
842920
] = getValuesTypes(storeInstance, storeType);
@@ -848,8 +926,10 @@ export const getStoreCoreApi = (
848926
valuesWhenSetType,
849927
valueIdType,
850928
valueCallbackType,
929+
hasValuesListenerType,
851930
valuesListenerType,
852931
valueIdsListenerType,
932+
hasValueListenerType,
853933
valueListenerType,
854934
invalidValueListenerType,
855935
);
@@ -858,8 +938,10 @@ export const getStoreCoreApi = (
858938
valuesType,
859939
valuesWhenSetType,
860940
valueIdType,
941+
hasValuesListenerType,
861942
valuesListenerType,
862943
valueIdsListenerType,
944+
hasValueListenerType,
863945
valueListenerType,
864946
];
865947

@@ -949,6 +1031,13 @@ export const getStoreCoreApi = (
9491031
'values' + JSON,
9501032
);
9511033

1034+
// addHasValuesListener
1035+
addProxyListener(
1036+
HAS + VALUES,
1037+
hasValuesListenerType,
1038+
getTheContentOfTheStoreDoc(2, 8, 0, 1) + ' changes',
1039+
);
1040+
9521041
// addValuesListener
9531042
addProxyListener(
9541043
VALUES,
@@ -959,6 +1048,15 @@ export const getStoreCoreApi = (
9591048
// addValueIdsListener
9601049
addProxyListener(VALUE_IDS, valueIdsListenerType, getListenerDoc(10, 0, 1));
9611050

1051+
// addHasValueListener
1052+
addProxyListener(
1053+
HAS + VALUE,
1054+
hasValueListenerType,
1055+
getListenerDoc(11, 0, 0, 1),
1056+
`valueId: ${valueIdType} | null`,
1057+
'valueId',
1058+
);
1059+
9621060
// addValueListener
9631061
addProxyListener(
9641062
VALUE,

0 commit comments

Comments
 (0)