tinybase 1.3.4 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/debug/checkpoints.js +67 -54
- package/lib/debug/indexes.js +104 -67
- package/lib/debug/metrics.js +185 -129
- package/lib/debug/persisters.js +2 -1
- package/lib/debug/queries.d.ts +3054 -0
- package/lib/debug/queries.js +880 -0
- package/lib/debug/relationships.d.ts +6 -5
- package/lib/debug/relationships.js +102 -66
- package/lib/debug/store.d.ts +137 -66
- package/lib/debug/store.js +215 -119
- package/lib/debug/tinybase.d.ts +1 -0
- package/lib/debug/tinybase.js +892 -175
- package/lib/debug/ui-react.d.ts +2004 -195
- package/lib/debug/ui-react.js +273 -77
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/queries.d.ts +3054 -0
- package/lib/queries.js +1 -0
- package/lib/queries.js.gz +0 -0
- package/lib/relationships.d.ts +6 -5
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.d.ts +137 -66
- package/lib/store.js +1 -1
- package/lib/store.js.gz +0 -0
- package/lib/tinybase.d.ts +1 -0
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/ui-react.d.ts +2004 -195
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/checkpoints.js +1 -1
- package/lib/umd/checkpoints.js.gz +0 -0
- package/lib/umd/indexes.js +1 -1
- package/lib/umd/indexes.js.gz +0 -0
- package/lib/umd/metrics.js +1 -1
- package/lib/umd/metrics.js.gz +0 -0
- package/lib/umd/queries.js +1 -0
- package/lib/umd/queries.js.gz +0 -0
- package/lib/umd/relationships.js +1 -1
- package/lib/umd/relationships.js.gz +0 -0
- package/lib/umd/store.js +1 -1
- package/lib/umd/store.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/package.json +22 -22
- package/readme.md +2 -2
package/lib/debug/store.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export type Cell = string | number | boolean;
|
|
|
94
94
|
*
|
|
95
95
|
* This is used when describing a Cell that is present _or_ that is not present
|
|
96
96
|
* - such as when it has been deleted, or when describing a previous state where
|
|
97
|
-
*
|
|
97
|
+
* the Cell value has since been added.
|
|
98
98
|
*
|
|
99
99
|
* @category Store
|
|
100
100
|
*/
|
|
@@ -327,7 +327,6 @@ export type RowListener = (
|
|
|
327
327
|
* @param store A reference to the Store that changed.
|
|
328
328
|
* @param tableId The Id of the Table that changed.
|
|
329
329
|
* @param rowId The Id of the Row that changed.
|
|
330
|
-
* changes.
|
|
331
330
|
* @category Listener
|
|
332
331
|
*/
|
|
333
332
|
export type CellIdsListener = (store: Store, tableId: Id, rowId: Id) => void;
|
|
@@ -390,6 +389,7 @@ export type CellListener = (
|
|
|
390
389
|
* @param cellId The Id of the Cell that was being changed.
|
|
391
390
|
* @param invalidCells An array of the values of the Cell that were invalid.
|
|
392
391
|
* @category Listener
|
|
392
|
+
* @since v1.1.0
|
|
393
393
|
*/
|
|
394
394
|
export type InvalidCellListener = (
|
|
395
395
|
store: Store,
|
|
@@ -420,9 +420,9 @@ export type GetCellChange = (tableId: Id, rowId: Id, cellId: Id) => CellChange;
|
|
|
420
420
|
* The CellChange type describes a Cell's changes during a transaction.
|
|
421
421
|
*
|
|
422
422
|
* This is returned by the GetCellChange function that is provided to every
|
|
423
|
-
* listener when called. This array contains the previous value of a Cell
|
|
424
|
-
*
|
|
425
|
-
*
|
|
423
|
+
* listener when called. This array contains the previous value of a Cell before
|
|
424
|
+
* the current transaction, the new value after it, and a convenience flag that
|
|
425
|
+
* indicates that the value has changed.
|
|
426
426
|
*
|
|
427
427
|
* @category Listener
|
|
428
428
|
*/
|
|
@@ -521,6 +521,7 @@ export type CellSchema =
|
|
|
521
521
|
* different value and then changed back.
|
|
522
522
|
*
|
|
523
523
|
* @category Transaction
|
|
524
|
+
* @since v1.2.0
|
|
524
525
|
*/
|
|
525
526
|
export type ChangedCells = {
|
|
526
527
|
[tableId: Id]: {
|
|
@@ -538,11 +539,12 @@ export type ChangedCells = {
|
|
|
538
539
|
* the transaction method. See that method for specific examples.
|
|
539
540
|
*
|
|
540
541
|
* This type is a nested structure of Table, Row, and Cell objects, much like
|
|
541
|
-
* the Tables object, but one for which Cell values are listed in array
|
|
542
|
-
*
|
|
543
|
-
*
|
|
542
|
+
* the Tables object, but one for which Cell values are listed in array (much
|
|
543
|
+
* like the InvalidCellListener type) so that multiple failed attempts to change
|
|
544
|
+
* a Cell during the transaction are described.
|
|
544
545
|
*
|
|
545
546
|
* @category Transaction
|
|
547
|
+
* @since v1.2.0
|
|
546
548
|
*/
|
|
547
549
|
export type InvalidCells = {
|
|
548
550
|
[tableId: Id]: {
|
|
@@ -791,9 +793,9 @@ export interface Store {
|
|
|
791
793
|
* The getTableIds method returns the Ids of every Table in the Store.
|
|
792
794
|
*
|
|
793
795
|
* Note that this returns a copy of, rather than a reference, to the list of
|
|
794
|
-
* Ids, so changes made to the list are not made to the Store itself.
|
|
795
|
-
* the order
|
|
796
|
-
*
|
|
796
|
+
* Ids, so changes made to the list are not made to the Store itself. Since
|
|
797
|
+
* v2.0.0, the order is significant: this method will return the Ids in the
|
|
798
|
+
* order in which each Table was added.
|
|
797
799
|
*
|
|
798
800
|
* @returns An array of the Ids of every Table in the Store.
|
|
799
801
|
* @example
|
|
@@ -858,9 +860,9 @@ export interface Store {
|
|
|
858
860
|
* The getRowIds method returns the Ids of every Row in a given Table.
|
|
859
861
|
*
|
|
860
862
|
* Note that this returns a copy of, rather than a reference, to the list of
|
|
861
|
-
* Ids, so changes made to the list are not made to the Store itself.
|
|
862
|
-
* the order
|
|
863
|
-
*
|
|
863
|
+
* Ids, so changes made to the list are not made to the Store itself. Since
|
|
864
|
+
* v2.0.0, the order is significant: this method will return the Ids in the
|
|
865
|
+
* order in which each Row was added.
|
|
864
866
|
*
|
|
865
867
|
* @param tableId The Id of the Table in the Store.
|
|
866
868
|
* @returns An array of the Ids of every Row in the Table.
|
|
@@ -932,9 +934,9 @@ export interface Store {
|
|
|
932
934
|
* given Table.
|
|
933
935
|
*
|
|
934
936
|
* Note that this returns a copy of, rather than a reference, to the list of
|
|
935
|
-
* Ids, so changes made to the list are not made to the Store itself.
|
|
936
|
-
* the order
|
|
937
|
-
*
|
|
937
|
+
* Ids, so changes made to the list are not made to the Store itself. Since
|
|
938
|
+
* v2.0.0, the order is significant: this method will return the Ids in the
|
|
939
|
+
* order in which each Cell was added.
|
|
938
940
|
*
|
|
939
941
|
* @param tableId The Id of the Table in the Store.
|
|
940
942
|
* @param rowId The Id of the Row in the Table.
|
|
@@ -965,17 +967,13 @@ export interface Store {
|
|
|
965
967
|
getCellIds(tableId: Id, rowId: Id): Ids;
|
|
966
968
|
|
|
967
969
|
/**
|
|
968
|
-
* The getCell method returns
|
|
969
|
-
*
|
|
970
|
-
*
|
|
971
|
-
* Note that this returns a copy of, rather than a reference to the underlying
|
|
972
|
-
* data, so changes made to the returned object are not made to the Store
|
|
973
|
-
* itself.
|
|
970
|
+
* The getCell method returns the value of a single Cell in a given Row, in a
|
|
971
|
+
* given Table.
|
|
974
972
|
*
|
|
975
973
|
* @param tableId The Id of the Table in the Store.
|
|
976
974
|
* @param rowId The Id of the Row in the Table.
|
|
977
975
|
* @param cellId The Id of the Cell in the Row.
|
|
978
|
-
* @returns The value of the Cell
|
|
976
|
+
* @returns The value of the Cell, or `undefined`.
|
|
979
977
|
* @example
|
|
980
978
|
* This example retrieves a single Cell.
|
|
981
979
|
*
|
|
@@ -1710,7 +1708,7 @@ export interface Store {
|
|
|
1710
1708
|
*
|
|
1711
1709
|
* @param actions The function to be executed as a transaction.
|
|
1712
1710
|
* @param doRollback An optional callback that should return `true` if you
|
|
1713
|
-
* want to rollback the transaction at the end.
|
|
1711
|
+
* want to rollback the transaction at the end. Since v1.2.0.
|
|
1714
1712
|
* @returns Whatever value the provided transaction function returns.
|
|
1715
1713
|
* @example
|
|
1716
1714
|
* This example makes changes to two Cells, first outside, and secondly
|
|
@@ -1846,6 +1844,7 @@ export interface Store {
|
|
|
1846
1844
|
* // -> 'Fido changed'
|
|
1847
1845
|
* ```
|
|
1848
1846
|
* @category Transaction
|
|
1847
|
+
* @since v1.3.0
|
|
1849
1848
|
*/
|
|
1850
1849
|
startTransaction(): Store;
|
|
1851
1850
|
|
|
@@ -1923,6 +1922,7 @@ export interface Store {
|
|
|
1923
1922
|
* // -> {pets: {fido: {species: 'dog', color: 'brown'}}}
|
|
1924
1923
|
* ```
|
|
1925
1924
|
* @category Transaction
|
|
1925
|
+
* @since v1.3.0
|
|
1926
1926
|
*/
|
|
1927
1927
|
finishTransaction(
|
|
1928
1928
|
doRollback?: (
|
|
@@ -2095,12 +2095,19 @@ export interface Store {
|
|
|
2095
2095
|
* The addTableIdsListener method registers a listener function with the Store
|
|
2096
2096
|
* that will be called whenever the Table Ids in the Store change.
|
|
2097
2097
|
*
|
|
2098
|
-
* Such a listener is only called when a Table is added or removed. To listen
|
|
2099
|
-
* to all changes in the Store, use the addTablesListener method.
|
|
2100
|
-
*
|
|
2101
2098
|
* The provided listener is a TableIdsListener function, and will be called
|
|
2102
2099
|
* with a reference to the Store.
|
|
2103
2100
|
*
|
|
2101
|
+
* By default, such a listener is only called when a Table is added or
|
|
2102
|
+
* removed. To listen to all changes in the Store, use the addTablesListener
|
|
2103
|
+
* method.
|
|
2104
|
+
*
|
|
2105
|
+
* Since v2.0.0, you can use the optional `trackReorder` parameter to
|
|
2106
|
+
* additionally track when the set of Ids has not changed, but the order has -
|
|
2107
|
+
* for example when a Table from the middle of the Store is removed and then
|
|
2108
|
+
* added back within the same transaction. This behavior is disabled by
|
|
2109
|
+
* default due to the potential performance cost of detecting such changes.
|
|
2110
|
+
*
|
|
2104
2111
|
* Use the optional mutator parameter to indicate that there is code in the
|
|
2105
2112
|
* listener that will mutate Store data. If set to `false` (or omitted), such
|
|
2106
2113
|
* mutations will be silently ignored. All relevant mutator listeners (with
|
|
@@ -2111,6 +2118,9 @@ export interface Store {
|
|
|
2111
2118
|
*
|
|
2112
2119
|
* @param listener The function that will be called whenever the Table Ids in
|
|
2113
2120
|
* the Store change.
|
|
2121
|
+
* @param trackReorder An optional boolean that indicates that the listener
|
|
2122
|
+
* should be called if the set of Ids remains the same but their order
|
|
2123
|
+
* changes.
|
|
2114
2124
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
2115
2125
|
* Store data.
|
|
2116
2126
|
* @returns A unique Id for the listener that can later be used to call it
|
|
@@ -2140,7 +2150,8 @@ export interface Store {
|
|
|
2140
2150
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
2141
2151
|
* const listenerId = store.addTableIdsListener(
|
|
2142
2152
|
* (store) => store.setCell('meta', 'update', 'store', true),
|
|
2143
|
-
*
|
|
2153
|
+
* false, // track reorder
|
|
2154
|
+
* true, // mutator
|
|
2144
2155
|
* );
|
|
2145
2156
|
*
|
|
2146
2157
|
* store.setTable('species', {dog: {price: 5}});
|
|
@@ -2151,21 +2162,25 @@ export interface Store {
|
|
|
2151
2162
|
* ```
|
|
2152
2163
|
* @category Listener
|
|
2153
2164
|
*/
|
|
2154
|
-
addTableIdsListener(
|
|
2165
|
+
addTableIdsListener(
|
|
2166
|
+
listener: TableIdsListener,
|
|
2167
|
+
trackReorder?: boolean,
|
|
2168
|
+
mutator?: boolean,
|
|
2169
|
+
): Id;
|
|
2155
2170
|
|
|
2156
2171
|
/**
|
|
2157
2172
|
* The addTableListener method registers a listener function with the Store
|
|
2158
2173
|
* that will be called whenever data in a Table changes.
|
|
2159
2174
|
*
|
|
2160
|
-
* You can either listen to a single Table (by specifying its Id as the
|
|
2161
|
-
* method's first parameter) or changes to any Table (by providing a `null`
|
|
2162
|
-
* wildcard).
|
|
2163
|
-
*
|
|
2164
2175
|
* The provided listener is a TableListener function, and will be called with
|
|
2165
2176
|
* a reference to the Store, the Id of the Table that changed, and a
|
|
2166
2177
|
* GetCellChange function in case you need to inspect any changes that
|
|
2167
2178
|
* occurred.
|
|
2168
2179
|
*
|
|
2180
|
+
* You can either listen to a single Table (by specifying its Id as the
|
|
2181
|
+
* method's first parameter) or changes to any Table (by providing a `null`
|
|
2182
|
+
* wildcard).
|
|
2183
|
+
*
|
|
2169
2184
|
* Use the optional mutator parameter to indicate that there is code in the
|
|
2170
2185
|
* listener that will mutate Store data. If set to `false` (or omitted), such
|
|
2171
2186
|
* mutations will be silently ignored. All relevant mutator listeners (with
|
|
@@ -2254,14 +2269,21 @@ export interface Store {
|
|
|
2254
2269
|
* The addRowIdsListener method registers a listener function with the Store
|
|
2255
2270
|
* that will be called whenever the Row Ids in a Table change.
|
|
2256
2271
|
*
|
|
2257
|
-
*
|
|
2258
|
-
*
|
|
2272
|
+
* The provided listener is a RowIdsListener function, and will be called with
|
|
2273
|
+
* a reference to the Store and the Id of the Table that changed.
|
|
2274
|
+
*
|
|
2275
|
+
* By default, such a listener is only called when a Row is added or removed.
|
|
2276
|
+
* To listen to all changes in the Table, use the addTableListener method.
|
|
2259
2277
|
*
|
|
2260
2278
|
* You can either listen to a single Table (by specifying its Id as the
|
|
2261
|
-
* method's first parameter) or changes to any Table (by providing `null`
|
|
2279
|
+
* method's first parameter) or changes to any Table (by providing a `null`
|
|
2280
|
+
* wildcard).
|
|
2262
2281
|
*
|
|
2263
|
-
*
|
|
2264
|
-
*
|
|
2282
|
+
* Since v2.0.0, you can use the optional `trackReorder` parameter to
|
|
2283
|
+
* additionally track when the set of Ids has not changed, but the order has -
|
|
2284
|
+
* for example when a Row from the middle of the Table is removed and then
|
|
2285
|
+
* added back within the same transaction. This behavior is disabled by
|
|
2286
|
+
* default due to the potential performance cost of detecting such changes.
|
|
2265
2287
|
*
|
|
2266
2288
|
* Use the optional mutator parameter to indicate that there is code in the
|
|
2267
2289
|
* listener that will mutate Store data. If set to `false` (or omitted), such
|
|
@@ -2274,6 +2296,9 @@ export interface Store {
|
|
|
2274
2296
|
* @param tableId The Id of the Table to listen to, or `null` as a wildcard.
|
|
2275
2297
|
* @param listener The function that will be called whenever the Row Ids in
|
|
2276
2298
|
* the Table change.
|
|
2299
|
+
* @param trackReorder An optional boolean that indicates that the listener
|
|
2300
|
+
* should be called if the set of Ids remains the same but their order
|
|
2301
|
+
* changes.
|
|
2277
2302
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
2278
2303
|
* Store data.
|
|
2279
2304
|
* @returns A unique Id for the listener that can later be used to call it
|
|
@@ -2296,6 +2321,36 @@ export interface Store {
|
|
|
2296
2321
|
* store.delListener(listenerId);
|
|
2297
2322
|
* ```
|
|
2298
2323
|
* @example
|
|
2324
|
+
* This example registers a listener that responds to a change of order in the
|
|
2325
|
+
* rows of a specific Table, even though the set of Ids themselves has not
|
|
2326
|
+
* changed.
|
|
2327
|
+
*
|
|
2328
|
+
* ```js
|
|
2329
|
+
* const store = createStore().setTables({
|
|
2330
|
+
* pets: {
|
|
2331
|
+
* fido: {species: 'dog'},
|
|
2332
|
+
* felix: {species: 'cat'},
|
|
2333
|
+
* },
|
|
2334
|
+
* });
|
|
2335
|
+
* const listenerId = store.addRowIdsListener(
|
|
2336
|
+
* 'pets',
|
|
2337
|
+
* (store) => {
|
|
2338
|
+
* console.log('Row Ids or order for pets table changed');
|
|
2339
|
+
* console.log(store.getRowIds('pets'));
|
|
2340
|
+
* },
|
|
2341
|
+
* true, // track reorder
|
|
2342
|
+
* );
|
|
2343
|
+
*
|
|
2344
|
+
* store.transaction(() => {
|
|
2345
|
+
* store.delRow('pets', 'fido');
|
|
2346
|
+
* store.setRow('pets', 'fido', {species: 'dog'});
|
|
2347
|
+
* });
|
|
2348
|
+
* // -> 'Row Ids or order for pets table changed'
|
|
2349
|
+
* // -> ['felix', 'fido']
|
|
2350
|
+
*
|
|
2351
|
+
* store.delListener(listenerId);
|
|
2352
|
+
* ```
|
|
2353
|
+
* @example
|
|
2299
2354
|
* This example registers a listener that responds to any change to the Row
|
|
2300
2355
|
* Ids of any Table.
|
|
2301
2356
|
*
|
|
@@ -2324,7 +2379,8 @@ export interface Store {
|
|
|
2324
2379
|
* const listenerId = store.addRowIdsListener(
|
|
2325
2380
|
* 'pets',
|
|
2326
2381
|
* (store, tableId) => store.setCell('meta', 'update', tableId, true),
|
|
2327
|
-
*
|
|
2382
|
+
* false, // track reorder
|
|
2383
|
+
* true, // mutator
|
|
2328
2384
|
* );
|
|
2329
2385
|
*
|
|
2330
2386
|
* store.setRow('pets', 'felix', {species: 'cat'});
|
|
@@ -2338,6 +2394,7 @@ export interface Store {
|
|
|
2338
2394
|
addRowIdsListener(
|
|
2339
2395
|
tableId: IdOrNull,
|
|
2340
2396
|
listener: RowIdsListener,
|
|
2397
|
+
trackReorder?: boolean,
|
|
2341
2398
|
mutator?: boolean,
|
|
2342
2399
|
): Id;
|
|
2343
2400
|
|
|
@@ -2345,6 +2402,11 @@ export interface Store {
|
|
|
2345
2402
|
* The addRowListener method registers a listener function with the Store that
|
|
2346
2403
|
* will be called whenever data in a Row changes.
|
|
2347
2404
|
*
|
|
2405
|
+
* The provided listener is a RowListener function, and will be called with a
|
|
2406
|
+
* reference to the Store, the Id of the Table that changed, the Id of the Row
|
|
2407
|
+
* that changed, and a GetCellChange function in case you need to inspect any
|
|
2408
|
+
* changes that occurred.
|
|
2409
|
+
*
|
|
2348
2410
|
* You can either listen to a single Row (by specifying the Table Id and Row
|
|
2349
2411
|
* Id as the method's first two parameters) or changes to any Row (by
|
|
2350
2412
|
* providing `null` wildcards).
|
|
@@ -2354,11 +2416,6 @@ export interface Store {
|
|
|
2354
2416
|
* Table, any Row in a specific Table, a specific Row in any Table, or any Row
|
|
2355
2417
|
* in any Table.
|
|
2356
2418
|
*
|
|
2357
|
-
* The provided listener is a RowListener function, and will be called with a
|
|
2358
|
-
* reference to the Store, the Id of the Table that changed, the Id of the Row
|
|
2359
|
-
* that changed, and a GetCellChange function in case you need to inspect any
|
|
2360
|
-
* changes that occurred.
|
|
2361
|
-
*
|
|
2362
2419
|
* Use the optional mutator parameter to indicate that there is code in the
|
|
2363
2420
|
* listener that will mutate Store data. If set to `false` (or omitted), such
|
|
2364
2421
|
* mutations will be silently ignored. All relevant mutator listeners (with
|
|
@@ -2455,21 +2512,27 @@ export interface Store {
|
|
|
2455
2512
|
* The addCellIdsListener method registers a listener function with the Store
|
|
2456
2513
|
* that will be called whenever the Cell Ids in a Row change.
|
|
2457
2514
|
*
|
|
2458
|
-
*
|
|
2459
|
-
* to
|
|
2515
|
+
* The provided listener is a CellIdsListener function, and will be called
|
|
2516
|
+
* with a reference to the Store, the Id of the Table, and the Id of the Row
|
|
2517
|
+
* that changed.
|
|
2518
|
+
*
|
|
2519
|
+
* By default, such a listener is only called when a Cell is added or removed.
|
|
2520
|
+
* To listen to all changes in the Row, use the addRowListener method.
|
|
2460
2521
|
*
|
|
2461
2522
|
* You can either listen to a single Row (by specifying the Table Id and Row
|
|
2462
2523
|
* Id as the method's first two parameters) or changes to any Row (by
|
|
2463
|
-
* providing `null`).
|
|
2524
|
+
* providing a `null` wildcard).
|
|
2464
2525
|
*
|
|
2465
2526
|
* Both, either, or neither of the `tableId` and `rowId` parameters can be
|
|
2466
2527
|
* wildcarded with `null`. You can listen to a specific Row in a specific
|
|
2467
2528
|
* Table, any Row in a specific Table, a specific Row in any Table, or any Row
|
|
2468
2529
|
* in any Table.
|
|
2469
2530
|
*
|
|
2470
|
-
*
|
|
2471
|
-
*
|
|
2472
|
-
*
|
|
2531
|
+
* Since v2.0.0, you can use the optional `trackReorder` parameter to
|
|
2532
|
+
* additionally track when the set of Ids has not changed, but the order has -
|
|
2533
|
+
* for example when a Cell from the middle of the Row is removed and then
|
|
2534
|
+
* added back within the same transaction. This behavior is disabled by
|
|
2535
|
+
* default due to the potential performance cost of detecting such changes.
|
|
2473
2536
|
*
|
|
2474
2537
|
* Use the optional mutator parameter to indicate that there is code in the
|
|
2475
2538
|
* listener that will mutate Store data. If set to `false` (or omitted), such
|
|
@@ -2483,6 +2546,9 @@ export interface Store {
|
|
|
2483
2546
|
* @param rowId The Id of the Row to listen to, or `null` as a wildcard.
|
|
2484
2547
|
* @param listener The function that will be called whenever the Cell Ids in
|
|
2485
2548
|
* the Row change.
|
|
2549
|
+
* @param trackReorder An optional boolean that indicates that the listener
|
|
2550
|
+
* should be called if the set of Ids remains the same but their order
|
|
2551
|
+
* changes.
|
|
2486
2552
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
2487
2553
|
* Store data.
|
|
2488
2554
|
* @returns A unique Id for the listener that can later be used to call it
|
|
@@ -2539,7 +2605,8 @@ export interface Store {
|
|
|
2539
2605
|
* 'fido',
|
|
2540
2606
|
* (store, tableId, rowId) =>
|
|
2541
2607
|
* store.setCell('meta', 'update', `${tableId}_${rowId}`, true),
|
|
2542
|
-
*
|
|
2608
|
+
* false, // track reorder
|
|
2609
|
+
* true, // mutator
|
|
2543
2610
|
* );
|
|
2544
2611
|
*
|
|
2545
2612
|
* store.setCell('pets', 'fido', 'color', 'brown');
|
|
@@ -2554,6 +2621,7 @@ export interface Store {
|
|
|
2554
2621
|
tableId: IdOrNull,
|
|
2555
2622
|
rowId: IdOrNull,
|
|
2556
2623
|
listener: CellIdsListener,
|
|
2624
|
+
trackReorder?: boolean,
|
|
2557
2625
|
mutator?: boolean,
|
|
2558
2626
|
): Id;
|
|
2559
2627
|
|
|
@@ -2561,6 +2629,12 @@ export interface Store {
|
|
|
2561
2629
|
* The addCellListener method registers a listener function with the Store
|
|
2562
2630
|
* that will be called whenever data in a Cell changes.
|
|
2563
2631
|
*
|
|
2632
|
+
* The provided listener is a CellListener function, and will be called with a
|
|
2633
|
+
* reference to the Store, the Id of the Table that changed, the Id of the Row
|
|
2634
|
+
* that changed, the Id of the Cell that changed, the new Cell value, the old
|
|
2635
|
+
* Cell value, and a GetCellChange function in case you need to inspect any
|
|
2636
|
+
* changes that occurred.
|
|
2637
|
+
*
|
|
2564
2638
|
* You can either listen to a single Cell (by specifying the Table Id, Row Id,
|
|
2565
2639
|
* and Cell Id as the method's first three parameters) or changes to any Cell
|
|
2566
2640
|
* (by providing `null` wildcards).
|
|
@@ -2570,12 +2644,6 @@ export interface Store {
|
|
|
2570
2644
|
* Row in a specific Table, any Cell in any Row in any Table, for example - or
|
|
2571
2645
|
* every other combination of wildcards.
|
|
2572
2646
|
*
|
|
2573
|
-
* The provided listener is a CellListener function, and will be called with a
|
|
2574
|
-
* reference to the Store, the Id of the Table that changed, the Id of the Row
|
|
2575
|
-
* that changed, the Id of the Cell that changed, the new Cell value, the old
|
|
2576
|
-
* Cell value, and a GetCellChange function in case you need to inspect any
|
|
2577
|
-
* changes that occurred.
|
|
2578
|
-
*
|
|
2579
2647
|
* Use the optional mutator parameter to indicate that there is code in the
|
|
2580
2648
|
* listener that will mutate Store data. If set to `false` (or omitted), such
|
|
2581
2649
|
* mutations will be silently ignored. All relevant mutator listeners (with
|
|
@@ -2682,6 +2750,14 @@ export interface Store {
|
|
|
2682
2750
|
* Store that will be called whenever invalid data was attempted to be written
|
|
2683
2751
|
* to a Cell.
|
|
2684
2752
|
*
|
|
2753
|
+
* The provided listener is an InvalidCellListener function, and will be
|
|
2754
|
+
* called with a reference to the Store, the Id of the Table, the Id of the
|
|
2755
|
+
* Row, and the Id of Cell that were being attempted to be changed. It is also
|
|
2756
|
+
* given the invalid value of the Cell, which could have been of absolutely
|
|
2757
|
+
* any type. Since there could have been multiple failed attempts to set the
|
|
2758
|
+
* Cell within a single transaction, this is an array containing each attempt,
|
|
2759
|
+
* chronologically.
|
|
2760
|
+
*
|
|
2685
2761
|
* You can either listen to a single Cell (by specifying the Table Id, Row Id,
|
|
2686
2762
|
* and Cell Id as the method's first three parameters) or invalid attempts to
|
|
2687
2763
|
* change any Cell (by providing `null` wildcards).
|
|
@@ -2691,14 +2767,6 @@ export interface Store {
|
|
|
2691
2767
|
* Row in a specific Table, any Cell in any Row in any Table, for example - or
|
|
2692
2768
|
* every other combination of wildcards.
|
|
2693
2769
|
*
|
|
2694
|
-
* The provided listener is an InvalidCellListener function, and will be
|
|
2695
|
-
* called with a reference to the Store, the Id of the Table, the Id of the
|
|
2696
|
-
* Row, and the Id of Cell that were being attempted to be changed. It is also
|
|
2697
|
-
* given the invalid value of the Cell, which could have been of absolutely
|
|
2698
|
-
* any type. Since there could have been multiple failed attempts to set the
|
|
2699
|
-
* Cell within a single transaction, this is an array containing each attempt,
|
|
2700
|
-
* chronologically.
|
|
2701
|
-
*
|
|
2702
2770
|
* Use the optional mutator parameter to indicate that there is code in the
|
|
2703
2771
|
* listener that will mutate Store data. If set to `false` (or omitted), such
|
|
2704
2772
|
* mutations will be silently ignored. All relevant mutator listeners (with
|
|
@@ -2897,6 +2965,7 @@ export interface Store {
|
|
|
2897
2965
|
* store.delListener(listenerId);
|
|
2898
2966
|
* ```
|
|
2899
2967
|
* @category Listener
|
|
2968
|
+
* @since v1.1.0
|
|
2900
2969
|
*/
|
|
2901
2970
|
addInvalidCellListener(
|
|
2902
2971
|
tableId: IdOrNull,
|
|
@@ -2971,6 +3040,7 @@ export interface Store {
|
|
|
2971
3040
|
* store.delListener(listenerId).delListener(listenerId2);
|
|
2972
3041
|
* ```
|
|
2973
3042
|
* @category Listener
|
|
3043
|
+
* @since v1.3.0
|
|
2974
3044
|
*/
|
|
2975
3045
|
addWillFinishTransactionListener(listener: TransactionListener): Id;
|
|
2976
3046
|
|
|
@@ -3040,6 +3110,7 @@ export interface Store {
|
|
|
3040
3110
|
* store.delListener(listenerId).delListener(listenerId2);
|
|
3041
3111
|
* ```
|
|
3042
3112
|
* @category Listener
|
|
3113
|
+
* @since v1.3.0
|
|
3043
3114
|
*/
|
|
3044
3115
|
addDidFinishTransactionListener(listener: TransactionListener): Id;
|
|
3045
3116
|
|