tinybase 0.9.0 → 0.9.4
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.d.ts +35 -20
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/common.d.ts +56 -0
- package/lib/common.js +1 -0
- package/lib/common.js.gz +0 -0
- package/lib/debug/checkpoints.d.ts +35 -20
- package/lib/debug/checkpoints.js +1 -1
- package/lib/debug/common.d.ts +56 -0
- package/lib/debug/common.js +3 -0
- package/lib/debug/indexes.d.ts +35 -76
- package/lib/debug/indexes.js +18 -10
- package/lib/debug/metrics.d.ts +45 -20
- package/lib/debug/metrics.js +1 -1
- package/lib/debug/persisters.d.ts +203 -17
- package/lib/debug/persisters.js +1 -1
- package/lib/debug/relationships.d.ts +46 -23
- package/lib/debug/relationships.js +1 -1
- package/lib/debug/store.d.ts +179 -102
- package/lib/debug/store.js +1 -1
- package/lib/debug/tinybase.d.ts +1 -2
- package/lib/debug/tinybase.js +18 -1029
- package/lib/debug/{react.d.ts → ui-react.d.ts} +262 -162
- package/lib/debug/{react.js → ui-react.js} +24 -15
- package/lib/indexes.d.ts +35 -76
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.d.ts +45 -20
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/persisters.d.ts +203 -17
- package/lib/persisters.js +1 -1
- package/lib/persisters.js.gz +0 -0
- package/lib/relationships.d.ts +46 -23
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.d.ts +179 -102
- package/lib/store.js +1 -1
- package/lib/store.js.gz +0 -0
- package/lib/tinybase.d.ts +1 -2
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/{react.d.ts → ui-react.d.ts} +262 -162
- package/lib/ui-react.js +1 -0
- 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/common.js +1 -0
- package/lib/umd/common.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/persisters.js +1 -1
- package/lib/umd/persisters.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 -0
- package/lib/umd/ui-react.js.gz +0 -0
- package/package.json +21 -16
- package/readme.md +13 -13
- package/lib/react.js +0 -1
- package/lib/react.js.gz +0 -0
- package/lib/umd/react.js +0 -1
- package/lib/umd/react.js.gz +0 -0
package/lib/debug/store.d.ts
CHANGED
|
@@ -17,14 +17,13 @@ import {Id, IdOrNull, Ids, Json} from './common.d';
|
|
|
17
17
|
* The Tables type is the data structure representing all of the data in a
|
|
18
18
|
* Store.
|
|
19
19
|
*
|
|
20
|
-
* A Tables object
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* individual Table objects, keyed by their Id.
|
|
20
|
+
* A Tables object is used when setting all of the tables together with the
|
|
21
|
+
* setTables method, and when getting them back out again with the getTables
|
|
22
|
+
* method. A Tables object is a regular JavaScript object containing individual
|
|
23
|
+
* Table objects, keyed by their Id.
|
|
25
24
|
*
|
|
26
25
|
* @example
|
|
27
|
-
* ```
|
|
26
|
+
* ```js
|
|
28
27
|
* const tables: Tables = {
|
|
29
28
|
* pets: {
|
|
30
29
|
* fido: {species: 'dog', color: 'brown'},
|
|
@@ -49,7 +48,7 @@ export type Tables = {[tableId: Id]: Table};
|
|
|
49
48
|
* Id.
|
|
50
49
|
*
|
|
51
50
|
* @example
|
|
52
|
-
* ```
|
|
51
|
+
* ```js
|
|
53
52
|
* const table: Table = {
|
|
54
53
|
* fido: {species: 'dog', color: 'brown'},
|
|
55
54
|
* felix: {species: 'cat'},
|
|
@@ -67,7 +66,7 @@ export type Table = {[rowId: Id]: Row};
|
|
|
67
66
|
* object containing individual Cell objects, keyed by their Id.
|
|
68
67
|
*
|
|
69
68
|
* @example
|
|
70
|
-
* ```
|
|
69
|
+
* ```js
|
|
71
70
|
* const row: Row = {species: 'dog', color: 'brown'};
|
|
72
71
|
* ```
|
|
73
72
|
* @category Store
|
|
@@ -82,7 +81,7 @@ export type Row = {[cellId: Id]: Cell};
|
|
|
82
81
|
* number, or boolean.
|
|
83
82
|
*
|
|
84
83
|
* @example
|
|
85
|
-
* ```
|
|
84
|
+
* ```js
|
|
86
85
|
* const cell: Cell = 'dog';
|
|
87
86
|
* ```
|
|
88
87
|
* @category Store
|
|
@@ -97,6 +96,9 @@ export type Cell = string | number | boolean;
|
|
|
97
96
|
* can do something based on every Table in the Store. See that method for
|
|
98
97
|
* specific examples.
|
|
99
98
|
*
|
|
99
|
+
* @param tableId The Id of the Table that the callback can operate on.
|
|
100
|
+
* @param forEachRow A function that will let you iterate over the Row objects
|
|
101
|
+
* in this Table.
|
|
100
102
|
* @category Callback
|
|
101
103
|
*/
|
|
102
104
|
export type TableCallback = (
|
|
@@ -112,6 +114,9 @@ export type TableCallback = (
|
|
|
112
114
|
* do something based on every Row in a Table. See that method for specific
|
|
113
115
|
* examples.
|
|
114
116
|
*
|
|
117
|
+
* @param rowId The Id of the Row that the callback can operate on.
|
|
118
|
+
* @param forEachRow A function that will let you iterate over the Cell values
|
|
119
|
+
* in this Row.
|
|
115
120
|
* @category Callback
|
|
116
121
|
*/
|
|
117
122
|
export type RowCallback = (
|
|
@@ -127,6 +132,8 @@ export type RowCallback = (
|
|
|
127
132
|
* do something based on every Cell in a Row. See that method for specific
|
|
128
133
|
* examples.
|
|
129
134
|
*
|
|
135
|
+
* @param cellId The Id of the Cell that the callback can operate on.
|
|
136
|
+
* @param cell The value of the Cell.
|
|
130
137
|
* @category Callback
|
|
131
138
|
*/
|
|
132
139
|
export type CellCallback = (cellId: Id, cell: Cell) => void;
|
|
@@ -139,6 +146,7 @@ export type CellCallback = (cellId: Id, cell: Cell) => void;
|
|
|
139
146
|
* new one, such as when incrementing a number. See that method for specific
|
|
140
147
|
* examples.
|
|
141
148
|
*
|
|
149
|
+
* @param cell The current value of the Cell to map to a new value.
|
|
142
150
|
* @category Callback
|
|
143
151
|
*/
|
|
144
152
|
export type MapCell = (cell: Cell | undefined) => Cell;
|
|
@@ -151,6 +159,7 @@ export type MapCell = (cell: Cell | undefined) => Cell;
|
|
|
151
159
|
* setMetricDefinition method of a Metrics object, or the setIndexDefinition
|
|
152
160
|
* method of an Indexes object. See those methods for specific examples.
|
|
153
161
|
*
|
|
162
|
+
* @param cellId The Id of the Cell to fetch the value for.
|
|
154
163
|
* @category Callback
|
|
155
164
|
*/
|
|
156
165
|
export type GetCell = (cellId: Id) => Cell | undefined;
|
|
@@ -170,6 +179,9 @@ export type GetCell = (cellId: Id) => Cell | undefined;
|
|
|
170
179
|
* callListener method rather than due to a real change in the Store), the
|
|
171
180
|
* GetCellChange function will not be present.
|
|
172
181
|
*
|
|
182
|
+
* @param store A reference to the Store that changed.
|
|
183
|
+
* @param getCellChange A function that returns information about any Cell's
|
|
184
|
+
* changes.
|
|
173
185
|
* @category Listener
|
|
174
186
|
*/
|
|
175
187
|
export type TablesListener = (
|
|
@@ -186,6 +198,7 @@ export type TablesListener = (
|
|
|
186
198
|
*
|
|
187
199
|
* When called, a TableIdsListener is given a reference to the Store.
|
|
188
200
|
*
|
|
201
|
+
* @param store A reference to the Store that changed.
|
|
189
202
|
* @category Listener
|
|
190
203
|
*/
|
|
191
204
|
export type TableIdsListener = (store: Store) => void;
|
|
@@ -205,6 +218,10 @@ export type TableIdsListener = (store: Store) => void;
|
|
|
205
218
|
* callListener method rather than due to a real change in the Store), the
|
|
206
219
|
* GetCellChange function will not be present.
|
|
207
220
|
*
|
|
221
|
+
* @param store A reference to the Store that changed.
|
|
222
|
+
* @param tableId The Id of the Table that changed.
|
|
223
|
+
* @param getCellChange A function that returns information about any Cell's
|
|
224
|
+
* changes.
|
|
208
225
|
* @category Listener
|
|
209
226
|
*/
|
|
210
227
|
export type TableListener = (
|
|
@@ -223,6 +240,8 @@ export type TableListener = (
|
|
|
223
240
|
* When called, a RowIdsListener is given a reference to the Store, and the Id
|
|
224
241
|
* of the Table whose Row Ids changed.
|
|
225
242
|
*
|
|
243
|
+
* @param store A reference to the Store that changed.
|
|
244
|
+
* @param tableId The Id of the Table that changed.
|
|
226
245
|
* @category Listener
|
|
227
246
|
*/
|
|
228
247
|
export type RowIdsListener = (store: Store, tableId: Id) => void;
|
|
@@ -243,6 +262,11 @@ export type RowIdsListener = (store: Store, tableId: Id) => void;
|
|
|
243
262
|
* callListener method rather than due to a real change in the Store), the
|
|
244
263
|
* GetCellChange function will not be present.
|
|
245
264
|
*
|
|
265
|
+
* @param store A reference to the Store that changed.
|
|
266
|
+
* @param tableId The Id of the Table that changed.
|
|
267
|
+
* @param rowId The Id of the Row that changed.
|
|
268
|
+
* @param getCellChange A function that returns information about any Cell's
|
|
269
|
+
* changes.
|
|
246
270
|
* @category Listener
|
|
247
271
|
*/
|
|
248
272
|
export type RowListener = (
|
|
@@ -262,6 +286,10 @@ export type RowListener = (
|
|
|
262
286
|
* When called, a CellIdsListener is given a reference to the Store, the Id of
|
|
263
287
|
* the Table that changed, and the Id of the Row whose Cell Ids changed.
|
|
264
288
|
*
|
|
289
|
+
* @param store A reference to the Store that changed.
|
|
290
|
+
* @param tableId The Id of the Table that changed.
|
|
291
|
+
* @param rowId The Id of the Row that changed.
|
|
292
|
+
* changes.
|
|
265
293
|
* @category Listener
|
|
266
294
|
*/
|
|
267
295
|
export type CellIdsListener = (store: Store, tableId: Id, rowId: Id) => void;
|
|
@@ -284,6 +312,14 @@ export type CellIdsListener = (store: Store, tableId: Id, rowId: Id) => void;
|
|
|
284
312
|
* GetCellChange function will not be present and the new and old values of the
|
|
285
313
|
* Cell will be the same.
|
|
286
314
|
*
|
|
315
|
+
* @param store A reference to the Store that changed.
|
|
316
|
+
* @param tableId The Id of the Table that changed.
|
|
317
|
+
* @param rowId The Id of the Row that changed.
|
|
318
|
+
* @param cellId The Id of the Cell that changed.
|
|
319
|
+
* @param newCell The new value of the Cell that changed.
|
|
320
|
+
* @param oldCell The old value of the Cell that changed.
|
|
321
|
+
* @param getCellChange A function that returns information about any Cell's
|
|
322
|
+
* changes.
|
|
287
323
|
* @category Listener
|
|
288
324
|
*/
|
|
289
325
|
export type CellListener = (
|
|
@@ -297,36 +333,52 @@ export type CellListener = (
|
|
|
297
333
|
) => void;
|
|
298
334
|
|
|
299
335
|
/**
|
|
300
|
-
* The GetCellChange type describes a function that returns information about
|
|
301
|
-
* Cell's changes during a transaction.
|
|
336
|
+
* The GetCellChange type describes a function that returns information about
|
|
337
|
+
* any Cell's changes during a transaction.
|
|
302
338
|
*
|
|
303
339
|
* A GetCellChange function is provided to every listener when called due the
|
|
304
340
|
* Store changing. The listener can then fetch the previous value of a Cell
|
|
305
341
|
* before the current transaction, the new value after it, and a convenience
|
|
306
342
|
* flag that indicates that the value has changed.
|
|
307
343
|
*
|
|
344
|
+
* @param tableId The Id of the Table to inspect.
|
|
345
|
+
* @param rowId The Id of the Row to inspect.
|
|
346
|
+
* @param cellId The Id of the Cell to inspect.
|
|
347
|
+
* @returns A CellChange array containing information about the Cell's changes.
|
|
308
348
|
* @category Listener
|
|
309
349
|
*/
|
|
310
|
-
export type GetCellChange = (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
350
|
+
export type GetCellChange = (tableId: Id, rowId: Id, cellId: Id) => CellChange;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The CellChange type describes a Cell's changes during a transaction.
|
|
354
|
+
*
|
|
355
|
+
* This is returned by the GetCellChange function that is provided to every
|
|
356
|
+
* listener when called. This array contains the previous value of a Cell
|
|
357
|
+
* before the current transaction, the new value after it, and a convenience
|
|
358
|
+
* flag that indicates that the value has changed.
|
|
359
|
+
*
|
|
360
|
+
* @category Listener
|
|
361
|
+
*/
|
|
362
|
+
export type CellChange = [
|
|
363
|
+
changed: boolean,
|
|
364
|
+
oldCell: Cell | undefined,
|
|
365
|
+
newCell: Cell | undefined,
|
|
366
|
+
];
|
|
315
367
|
|
|
316
368
|
/**
|
|
317
369
|
* The Schema type describes the structure of a Store in terms of valid Table
|
|
318
370
|
* Ids and the types of Cell that can exist within them.
|
|
319
371
|
*
|
|
320
372
|
* A Schema comprises a JavaScript object describing each Table, in turn a
|
|
321
|
-
* nested JavaScript object containing
|
|
322
|
-
*
|
|
373
|
+
* nested JavaScript object containing information about each Cell and its
|
|
374
|
+
* CellSchema. It is provided to the setSchema method.
|
|
323
375
|
*
|
|
324
376
|
* @example
|
|
325
377
|
* When applied to a Store, this Schema only allows one Table called `pets`, in
|
|
326
378
|
* which each Row may contain a string `species` Cell, and is guaranteed to
|
|
327
379
|
* contain a boolean `sold` Cell that defaults to `false`.
|
|
328
380
|
*
|
|
329
|
-
*```
|
|
381
|
+
*```js
|
|
330
382
|
* const schema: Schema = {
|
|
331
383
|
* pets: {
|
|
332
384
|
* species: {type: 'string'},
|
|
@@ -361,7 +413,7 @@ export type Schema = {
|
|
|
361
413
|
* When applied to a Store, this CellSchema ensures a boolean Cell is always
|
|
362
414
|
* present, and defaults it to `false`.
|
|
363
415
|
*
|
|
364
|
-
*```
|
|
416
|
+
*```js
|
|
365
417
|
* const requiredBoolean: CellSchema = {type: 'boolean', default: false};
|
|
366
418
|
* ```
|
|
367
419
|
* @category Schema
|
|
@@ -392,12 +444,33 @@ export type CellSchema =
|
|
|
392
444
|
* @category Development
|
|
393
445
|
*/
|
|
394
446
|
export type StoreListenerStats = {
|
|
447
|
+
/**
|
|
448
|
+
* The number of TablesListeners registered with the Store.
|
|
449
|
+
*/
|
|
395
450
|
tables?: number;
|
|
451
|
+
/**
|
|
452
|
+
* The number of TableIdsListeners registered with the Store.
|
|
453
|
+
*/
|
|
396
454
|
tableIds?: number;
|
|
455
|
+
/**
|
|
456
|
+
* The number of TableListeners registered with the Store.
|
|
457
|
+
*/
|
|
397
458
|
table?: number;
|
|
459
|
+
/**
|
|
460
|
+
* The number of RowIdsListeners registered with the Store.
|
|
461
|
+
*/
|
|
398
462
|
rowIds?: number;
|
|
463
|
+
/**
|
|
464
|
+
* The number of RowListeners registered with the Store.
|
|
465
|
+
*/
|
|
399
466
|
row?: number;
|
|
467
|
+
/**
|
|
468
|
+
* The number of CellIdsListeners registered with the Store.
|
|
469
|
+
*/
|
|
400
470
|
cellIds?: number;
|
|
471
|
+
/**
|
|
472
|
+
* The number of CellListeners registered with the Store.
|
|
473
|
+
*/
|
|
401
474
|
cell?: number;
|
|
402
475
|
};
|
|
403
476
|
|
|
@@ -467,10 +540,10 @@ export type StoreListenerStats = {
|
|
|
467
540
|
* |Cell Ids|getCellIds|-|-|addCellIdsListener|
|
|
468
541
|
* |Cell|getCell|setCell|delCell|addCellListener|
|
|
469
542
|
*
|
|
470
|
-
* Additionally, there are two extra methods to manipulate
|
|
471
|
-
* method is like the setRow method but automatically assigns it a new
|
|
472
|
-
* Id. And the setPartialRow method lets you update multiple Cell values
|
|
473
|
-
* Row without affecting the others.
|
|
543
|
+
* Additionally, there are two extra methods to manipulate Row objects. The
|
|
544
|
+
* addRow method is like the setRow method but automatically assigns it a new
|
|
545
|
+
* unique Id. And the setPartialRow method lets you update multiple Cell values
|
|
546
|
+
* in a Row without affecting the others.
|
|
474
547
|
*
|
|
475
548
|
* The transaction method is used to wrap multiple changes to the Store so that
|
|
476
549
|
* the relevant listeners only fire once.
|
|
@@ -521,7 +594,7 @@ export type StoreListenerStats = {
|
|
|
521
594
|
* This example shows a very simple lifecycle of a Store: from creation, to
|
|
522
595
|
* adding and getting some data, and then registering and removing a listener.
|
|
523
596
|
*
|
|
524
|
-
* ```
|
|
597
|
+
* ```js
|
|
525
598
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
526
599
|
* console.log(store.getRow('pets', 'fido'));
|
|
527
600
|
* // -> {species: 'dog'}
|
|
@@ -539,6 +612,7 @@ export type StoreListenerStats = {
|
|
|
539
612
|
*
|
|
540
613
|
* store.delListener(listenerId);
|
|
541
614
|
* ```
|
|
615
|
+
* @category Store
|
|
542
616
|
*/
|
|
543
617
|
export interface Store {
|
|
544
618
|
/**
|
|
@@ -553,7 +627,7 @@ export interface Store {
|
|
|
553
627
|
* @example
|
|
554
628
|
* This example retrieves the data in a Store.
|
|
555
629
|
*
|
|
556
|
-
* ```
|
|
630
|
+
* ```js
|
|
557
631
|
* const store = createStore().setTables({
|
|
558
632
|
* pets: {fido: {species: 'dog'}},
|
|
559
633
|
* species: {dog: {price: 5}},
|
|
@@ -565,7 +639,7 @@ export interface Store {
|
|
|
565
639
|
* This example retrieves the Tables of an empty Store, returning an empty
|
|
566
640
|
* object.
|
|
567
641
|
*
|
|
568
|
-
* ```
|
|
642
|
+
* ```js
|
|
569
643
|
* const store = createStore();
|
|
570
644
|
* console.log(store.getTables());
|
|
571
645
|
* // -> {}
|
|
@@ -590,7 +664,7 @@ export interface Store {
|
|
|
590
664
|
* @example
|
|
591
665
|
* This example retrieves the Table Ids in a Store.
|
|
592
666
|
*
|
|
593
|
-
* ```
|
|
667
|
+
* ```js
|
|
594
668
|
* const store = createStore().setTables({
|
|
595
669
|
* pets: {fido: {species: 'dog'}},
|
|
596
670
|
* species: {dog: {price: 5}},
|
|
@@ -602,7 +676,7 @@ export interface Store {
|
|
|
602
676
|
* This example retrieves the Table Ids of an empty Store, returning an empty
|
|
603
677
|
* array.
|
|
604
678
|
*
|
|
605
|
-
* ```
|
|
679
|
+
* ```js
|
|
606
680
|
* const store = createStore();
|
|
607
681
|
* console.log(store.getTableIds());
|
|
608
682
|
* // -> []
|
|
@@ -624,7 +698,7 @@ export interface Store {
|
|
|
624
698
|
* @example
|
|
625
699
|
* This example retrieves the data in a single Table.
|
|
626
700
|
*
|
|
627
|
-
* ```
|
|
701
|
+
* ```js
|
|
628
702
|
* const store = createStore().setTables({
|
|
629
703
|
* pets: {fido: {species: 'dog'}},
|
|
630
704
|
* species: {dog: {price: 5}},
|
|
@@ -636,7 +710,7 @@ export interface Store {
|
|
|
636
710
|
* This example retrieves a Table that does not exist, returning an empty
|
|
637
711
|
* object.
|
|
638
712
|
*
|
|
639
|
-
* ```
|
|
713
|
+
* ```js
|
|
640
714
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
641
715
|
* console.log(store.getTable('employees'));
|
|
642
716
|
* // -> {}
|
|
@@ -658,7 +732,7 @@ export interface Store {
|
|
|
658
732
|
* @example
|
|
659
733
|
* This example retrieves the Row Ids in a Table.
|
|
660
734
|
*
|
|
661
|
-
* ```
|
|
735
|
+
* ```js
|
|
662
736
|
* const store = createStore().setTables({
|
|
663
737
|
* pets: {
|
|
664
738
|
* fido: {species: 'dog'},
|
|
@@ -672,7 +746,7 @@ export interface Store {
|
|
|
672
746
|
* This example retrieves the Row Ids of a Table that does not exist,
|
|
673
747
|
* returning an empty array.
|
|
674
748
|
*
|
|
675
|
-
* ```
|
|
749
|
+
* ```js
|
|
676
750
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
677
751
|
* console.log(store.getRowIds('employees'));
|
|
678
752
|
* // -> []
|
|
@@ -695,7 +769,7 @@ export interface Store {
|
|
|
695
769
|
* @example
|
|
696
770
|
* This example retrieves the data in a single Row.
|
|
697
771
|
*
|
|
698
|
-
* ```
|
|
772
|
+
* ```js
|
|
699
773
|
* const store = createStore().setTables({
|
|
700
774
|
* pets: {
|
|
701
775
|
* fido: {species: 'dog'},
|
|
@@ -709,7 +783,7 @@ export interface Store {
|
|
|
709
783
|
* This example retrieves a Row that does not exist, returning an empty
|
|
710
784
|
* object.
|
|
711
785
|
*
|
|
712
|
-
* ```
|
|
786
|
+
* ```js
|
|
713
787
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
714
788
|
* console.log(store.getRow('pets', 'felix'));
|
|
715
789
|
* // -> {}
|
|
@@ -733,7 +807,7 @@ export interface Store {
|
|
|
733
807
|
* @example
|
|
734
808
|
* This example retrieves the Cell Ids in a Row.
|
|
735
809
|
*
|
|
736
|
-
* ```
|
|
810
|
+
* ```js
|
|
737
811
|
* const store = createStore().setTables({
|
|
738
812
|
* pets: {
|
|
739
813
|
* fido: {species: 'dog', color: 'brown'},
|
|
@@ -746,7 +820,7 @@ export interface Store {
|
|
|
746
820
|
* This example retrieves the Cell Ids of a Cell that does not exist,
|
|
747
821
|
* returning an empty array.
|
|
748
822
|
*
|
|
749
|
-
* ```
|
|
823
|
+
* ```js
|
|
750
824
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
751
825
|
* console.log(store.getCellIds('pets', 'felix'));
|
|
752
826
|
* // -> []
|
|
@@ -770,7 +844,7 @@ export interface Store {
|
|
|
770
844
|
* @example
|
|
771
845
|
* This example retrieves a single Cell.
|
|
772
846
|
*
|
|
773
|
-
* ```
|
|
847
|
+
* ```js
|
|
774
848
|
* const store = createStore().setTables({
|
|
775
849
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
776
850
|
* });
|
|
@@ -780,7 +854,7 @@ export interface Store {
|
|
|
780
854
|
* @example
|
|
781
855
|
* This example retrieves a Cell that does not exist, returning `undefined`.
|
|
782
856
|
*
|
|
783
|
-
* ```
|
|
857
|
+
* ```js
|
|
784
858
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
785
859
|
* console.log(store.getCell('pets', 'fido', 'color'));
|
|
786
860
|
* // -> undefined
|
|
@@ -798,7 +872,7 @@ export interface Store {
|
|
|
798
872
|
* @example
|
|
799
873
|
* This example shows two simple Table existence checks.
|
|
800
874
|
*
|
|
801
|
-
* ```
|
|
875
|
+
* ```js
|
|
802
876
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
803
877
|
* console.log(store.hasTable('pets'));
|
|
804
878
|
* // -> true
|
|
@@ -819,7 +893,7 @@ export interface Store {
|
|
|
819
893
|
* @example
|
|
820
894
|
* This example shows two simple Row existence checks.
|
|
821
895
|
*
|
|
822
|
-
* ```
|
|
896
|
+
* ```js
|
|
823
897
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
824
898
|
* console.log(store.hasRow('pets', 'fido'));
|
|
825
899
|
* // -> true
|
|
@@ -841,7 +915,7 @@ export interface Store {
|
|
|
841
915
|
* @example
|
|
842
916
|
* This example shows two simple Cell existence checks.
|
|
843
917
|
*
|
|
844
|
-
* ```
|
|
918
|
+
* ```js
|
|
845
919
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
846
920
|
* console.log(store.hasCell('pets', 'fido', 'species'));
|
|
847
921
|
* // -> true
|
|
@@ -860,7 +934,7 @@ export interface Store {
|
|
|
860
934
|
* @example
|
|
861
935
|
* This example serializes the contents of a Store.
|
|
862
936
|
*
|
|
863
|
-
* ```
|
|
937
|
+
* ```js
|
|
864
938
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
865
939
|
* console.log(store.getJson());
|
|
866
940
|
* // -> '{"pets":{"fido":{"species":"dog"}}}'
|
|
@@ -868,7 +942,7 @@ export interface Store {
|
|
|
868
942
|
* @example
|
|
869
943
|
* This example serializes the contents of an empty Store.
|
|
870
944
|
*
|
|
871
|
-
* ```
|
|
945
|
+
* ```js
|
|
872
946
|
* const store = createStore();
|
|
873
947
|
* console.log(store.getJson());
|
|
874
948
|
* // -> '{}'
|
|
@@ -889,7 +963,7 @@ export interface Store {
|
|
|
889
963
|
* @example
|
|
890
964
|
* This example serializes the Schema of a Store.
|
|
891
965
|
*
|
|
892
|
-
* ```
|
|
966
|
+
* ```js
|
|
893
967
|
* const store = createStore().setSchema({
|
|
894
968
|
* pets: {
|
|
895
969
|
* species: {type: 'string'},
|
|
@@ -902,7 +976,7 @@ export interface Store {
|
|
|
902
976
|
* @example
|
|
903
977
|
* This example serializes the Schema of an empty Store.
|
|
904
978
|
*
|
|
905
|
-
* ```
|
|
979
|
+
* ```js
|
|
906
980
|
* const store = createStore();
|
|
907
981
|
* console.log(store.getSchemaJson());
|
|
908
982
|
* // -> '{}'
|
|
@@ -932,7 +1006,7 @@ export interface Store {
|
|
|
932
1006
|
* @example
|
|
933
1007
|
* This example sets the data of a Store.
|
|
934
1008
|
*
|
|
935
|
-
* ```
|
|
1009
|
+
* ```js
|
|
936
1010
|
* const store = createStore().setTables({
|
|
937
1011
|
* pets: {fido: {species: 'dog'}},
|
|
938
1012
|
* species: {dog: {price: 5}},
|
|
@@ -944,7 +1018,7 @@ export interface Store {
|
|
|
944
1018
|
* This example attempts to set the data of an existing Store with partly
|
|
945
1019
|
* invalid, and then completely invalid, Tables objects.
|
|
946
1020
|
*
|
|
947
|
-
* ```
|
|
1021
|
+
* ```js
|
|
948
1022
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
949
1023
|
*
|
|
950
1024
|
* store.setTables({pets: {felix: {species: 'cat', bug: []}}});
|
|
@@ -983,7 +1057,7 @@ export interface Store {
|
|
|
983
1057
|
* @example
|
|
984
1058
|
* This example sets the data of a single Table.
|
|
985
1059
|
*
|
|
986
|
-
* ```
|
|
1060
|
+
* ```js
|
|
987
1061
|
* const store = createStore().setTable('pets', {
|
|
988
1062
|
* fido: {species: 'dog'},
|
|
989
1063
|
* felix: {species: 'cat'},
|
|
@@ -995,7 +1069,7 @@ export interface Store {
|
|
|
995
1069
|
* This example attempts to set the data of an existing Store with partly
|
|
996
1070
|
* invalid, and then completely invalid, Table objects.
|
|
997
1071
|
*
|
|
998
|
-
* ```
|
|
1072
|
+
* ```js
|
|
999
1073
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1000
1074
|
*
|
|
1001
1075
|
* store.setTable('pets', {felix: {species: 'cat', bug: []}});
|
|
@@ -1036,7 +1110,7 @@ export interface Store {
|
|
|
1036
1110
|
* @example
|
|
1037
1111
|
* This example sets the data of a single Row.
|
|
1038
1112
|
*
|
|
1039
|
-
* ```
|
|
1113
|
+
* ```js
|
|
1040
1114
|
* const store = createStore().setRow('pets', 'fido', {species: 'dog'});
|
|
1041
1115
|
* console.log(store.getTables());
|
|
1042
1116
|
* // -> {pets: {fido: {species: 'dog'}}}
|
|
@@ -1045,7 +1119,7 @@ export interface Store {
|
|
|
1045
1119
|
* This example attempts to set the data of an existing Store with partly
|
|
1046
1120
|
* invalid, and then completely invalid, Row objects.
|
|
1047
1121
|
*
|
|
1048
|
-
* ```
|
|
1122
|
+
* ```js
|
|
1049
1123
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1050
1124
|
*
|
|
1051
1125
|
* store.setRow('pets', 'fido', {color: 'brown', bug: []});
|
|
@@ -1085,7 +1159,7 @@ export interface Store {
|
|
|
1085
1159
|
* @example
|
|
1086
1160
|
* This example adds a single Row.
|
|
1087
1161
|
*
|
|
1088
|
-
* ```
|
|
1162
|
+
* ```js
|
|
1089
1163
|
* const store = createStore();
|
|
1090
1164
|
* console.log(store.addRow('pets', {species: 'dog'}));
|
|
1091
1165
|
* // -> '0'
|
|
@@ -1096,7 +1170,7 @@ export interface Store {
|
|
|
1096
1170
|
* This example attempts to add Rows to an existing Store with partly invalid,
|
|
1097
1171
|
* and then completely invalid, Row objects.
|
|
1098
1172
|
*
|
|
1099
|
-
* ```
|
|
1173
|
+
* ```js
|
|
1100
1174
|
* const store = createStore().setTables({pets: {'0': {species: 'dog'}}});
|
|
1101
1175
|
*
|
|
1102
1176
|
* console.log(store.addRow('pets', {species: 'cat', bug: []}));
|
|
@@ -1138,7 +1212,7 @@ export interface Store {
|
|
|
1138
1212
|
* @example
|
|
1139
1213
|
* This example sets some of the data of a single Row.
|
|
1140
1214
|
*
|
|
1141
|
-
* ```
|
|
1215
|
+
* ```js
|
|
1142
1216
|
* const store = createStore().setTables({
|
|
1143
1217
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1144
1218
|
* });
|
|
@@ -1150,7 +1224,7 @@ export interface Store {
|
|
|
1150
1224
|
* This example attempts to set some of the data of an existing Store with
|
|
1151
1225
|
* partly invalid, and then completely invalid, Row objects.
|
|
1152
1226
|
*
|
|
1153
|
-
* ```
|
|
1227
|
+
* ```js
|
|
1154
1228
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1155
1229
|
*
|
|
1156
1230
|
* store.setPartialRow('pets', 'fido', {color: 'brown', bug: []});
|
|
@@ -1192,7 +1266,7 @@ export interface Store {
|
|
|
1192
1266
|
* @example
|
|
1193
1267
|
* This example sets the value of a single Cell.
|
|
1194
1268
|
*
|
|
1195
|
-
* ```
|
|
1269
|
+
* ```js
|
|
1196
1270
|
* const store = createStore().setCell('pets', 'fido', 'species', 'dog');
|
|
1197
1271
|
* console.log(store.getTables());
|
|
1198
1272
|
* // -> {pets: {fido: {species: 'dog'}}}
|
|
@@ -1200,7 +1274,7 @@ export interface Store {
|
|
|
1200
1274
|
* @example
|
|
1201
1275
|
* This example sets the data of a single Cell by mapping the existing value.
|
|
1202
1276
|
*
|
|
1203
|
-
* ```
|
|
1277
|
+
* ```js
|
|
1204
1278
|
* const increment = (cell) => cell + 1;
|
|
1205
1279
|
* const store = createStore().setTables({pets: {fido: {visits: 1}}});
|
|
1206
1280
|
*
|
|
@@ -1212,7 +1286,7 @@ export interface Store {
|
|
|
1212
1286
|
* This example attempts to set the data of an existing Store with an invalid
|
|
1213
1287
|
* Cell value.
|
|
1214
1288
|
*
|
|
1215
|
-
* ```
|
|
1289
|
+
* ```js
|
|
1216
1290
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1217
1291
|
*
|
|
1218
1292
|
* store.setCell('pets', 'fido', 'bug', []);
|
|
@@ -1237,7 +1311,7 @@ export interface Store {
|
|
|
1237
1311
|
* @example
|
|
1238
1312
|
* This example sets the contents of a Store from a serialization.
|
|
1239
1313
|
*
|
|
1240
|
-
* ```
|
|
1314
|
+
* ```js
|
|
1241
1315
|
* const store = createStore();
|
|
1242
1316
|
* store.setJson('{"pets":{"fido":{"species":"dog"}}}');
|
|
1243
1317
|
* console.log(store.getTables());
|
|
@@ -1247,7 +1321,7 @@ export interface Store {
|
|
|
1247
1321
|
* This example attempts to set the contents of a Store from an invalid
|
|
1248
1322
|
* serialization.
|
|
1249
1323
|
*
|
|
1250
|
-
* ```
|
|
1324
|
+
* ```js
|
|
1251
1325
|
* const store = createStore();
|
|
1252
1326
|
* store.setJson('{"pets":{"fido":{');
|
|
1253
1327
|
* console.log(store.getTables());
|
|
@@ -1264,16 +1338,15 @@ export interface Store {
|
|
|
1264
1338
|
* applied or as invalid Table, Row, or Cell objects are removed. These
|
|
1265
1339
|
* changes will fire any listeners to that data, as expected.
|
|
1266
1340
|
*
|
|
1267
|
-
*
|
|
1268
|
-
*
|
|
1269
|
-
* completely remove an existing Schema with the delSchema method.
|
|
1341
|
+
* When no longer needed, you can also completely remove an existing Schema
|
|
1342
|
+
* with the delSchema method.
|
|
1270
1343
|
*
|
|
1271
1344
|
* @param schema The Schema to be set for the Store.
|
|
1272
1345
|
* @returns A reference to the Store.
|
|
1273
1346
|
* @example
|
|
1274
1347
|
* This example sets the Schema of a Store after it has been created.
|
|
1275
1348
|
*
|
|
1276
|
-
* ```
|
|
1349
|
+
* ```js
|
|
1277
1350
|
* const store = createStore().setSchema({
|
|
1278
1351
|
* pets: {
|
|
1279
1352
|
* species: {type: 'string'},
|
|
@@ -1295,7 +1368,7 @@ export interface Store {
|
|
|
1295
1368
|
* @example
|
|
1296
1369
|
* This example removes the data of a Store.
|
|
1297
1370
|
*
|
|
1298
|
-
* ```
|
|
1371
|
+
* ```js
|
|
1299
1372
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1300
1373
|
*
|
|
1301
1374
|
* store.delTables();
|
|
@@ -1314,7 +1387,7 @@ export interface Store {
|
|
|
1314
1387
|
* @example
|
|
1315
1388
|
* This example removes a Table from a Store.
|
|
1316
1389
|
*
|
|
1317
|
-
* ```
|
|
1390
|
+
* ```js
|
|
1318
1391
|
* const store = createStore().setTables({
|
|
1319
1392
|
* pets: {fido: {species: 'dog'}},
|
|
1320
1393
|
* species: {dog: {price: 5}},
|
|
@@ -1339,7 +1412,7 @@ export interface Store {
|
|
|
1339
1412
|
* @example
|
|
1340
1413
|
* This example removes a Row from a Table.
|
|
1341
1414
|
*
|
|
1342
|
-
* ```
|
|
1415
|
+
* ```js
|
|
1343
1416
|
* const store = createStore().setTables({
|
|
1344
1417
|
* pets: {fido: {species: 'dog'}, felix: {species: 'cat'}},
|
|
1345
1418
|
* });
|
|
@@ -1382,7 +1455,7 @@ export interface Store {
|
|
|
1382
1455
|
* @example
|
|
1383
1456
|
* This example removes a Cell from a Row without a Schema.
|
|
1384
1457
|
*
|
|
1385
|
-
* ```
|
|
1458
|
+
* ```js
|
|
1386
1459
|
* const store = createStore().setTables({
|
|
1387
1460
|
* pets: {fido: {species: 'dog', sold: true}},
|
|
1388
1461
|
* });
|
|
@@ -1395,7 +1468,7 @@ export interface Store {
|
|
|
1395
1468
|
* This example removes a Cell from a Row with a Schema that defaults its
|
|
1396
1469
|
* value.
|
|
1397
1470
|
*
|
|
1398
|
-
* ```
|
|
1471
|
+
* ```js
|
|
1399
1472
|
* const store = createStore()
|
|
1400
1473
|
* .setTables({
|
|
1401
1474
|
* pets: {fido: {species: 'dog', sold: true}},
|
|
@@ -1415,7 +1488,7 @@ export interface Store {
|
|
|
1415
1488
|
* This example removes a Cell from a Row with a Schema that defaults its
|
|
1416
1489
|
* value, but uses the `forceDel` parameter to override it.
|
|
1417
1490
|
*
|
|
1418
|
-
* ```
|
|
1491
|
+
* ```js
|
|
1419
1492
|
* const store = createStore()
|
|
1420
1493
|
* .setTables({
|
|
1421
1494
|
* pets: {fido: {species: 'dog', sold: true}, felix: {species: 'cat'}},
|
|
@@ -1442,7 +1515,7 @@ export interface Store {
|
|
|
1442
1515
|
* @example
|
|
1443
1516
|
* This example removes the Schema of a Store.
|
|
1444
1517
|
*
|
|
1445
|
-
* ```
|
|
1518
|
+
* ```js
|
|
1446
1519
|
* const store = createStore().setSchema({pets: {species: {type: 'string'}}});
|
|
1447
1520
|
* store.delSchema();
|
|
1448
1521
|
* console.log(store.getSchemaJson());
|
|
@@ -1481,7 +1554,7 @@ export interface Store {
|
|
|
1481
1554
|
* within, a transaction. In the second case, the Row listener is only called
|
|
1482
1555
|
* once.
|
|
1483
1556
|
*
|
|
1484
|
-
* ```
|
|
1557
|
+
* ```js
|
|
1485
1558
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1486
1559
|
* store.addRowListener('pets', 'fido', () => console.log('Fido changed'));
|
|
1487
1560
|
*
|
|
@@ -1501,7 +1574,7 @@ export interface Store {
|
|
|
1501
1574
|
* called once - and with the final value - only if there is a net overall
|
|
1502
1575
|
* change.
|
|
1503
1576
|
*
|
|
1504
|
-
* ```
|
|
1577
|
+
* ```js
|
|
1505
1578
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1506
1579
|
* store.addCellListener(
|
|
1507
1580
|
* 'pets',
|
|
@@ -1543,7 +1616,7 @@ export interface Store {
|
|
|
1543
1616
|
* This example iterates over each Table in a Store, and lists each Row Id
|
|
1544
1617
|
* within them.
|
|
1545
1618
|
*
|
|
1546
|
-
* ```
|
|
1619
|
+
* ```js
|
|
1547
1620
|
* const store = createStore().setTables({
|
|
1548
1621
|
* pets: {fido: {species: 'dog'}},
|
|
1549
1622
|
* species: {dog: {price: 5}},
|
|
@@ -1575,7 +1648,7 @@ export interface Store {
|
|
|
1575
1648
|
* This example iterates over each Row in a Table, and lists each Cell Id
|
|
1576
1649
|
* within them.
|
|
1577
1650
|
*
|
|
1578
|
-
* ```
|
|
1651
|
+
* ```js
|
|
1579
1652
|
* const store = createStore().setTables({
|
|
1580
1653
|
* pets: {
|
|
1581
1654
|
* fido: {species: 'dog'},
|
|
@@ -1607,7 +1680,7 @@ export interface Store {
|
|
|
1607
1680
|
* @example
|
|
1608
1681
|
* This example iterates over each Cell in a Row, and lists its value.
|
|
1609
1682
|
*
|
|
1610
|
-
* ```
|
|
1683
|
+
* ```js
|
|
1611
1684
|
* const store = createStore().setTables({
|
|
1612
1685
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1613
1686
|
* });
|
|
@@ -1647,7 +1720,7 @@ export interface Store {
|
|
|
1647
1720
|
* This example registers a listener that responds to any changes to the whole
|
|
1648
1721
|
* Store.
|
|
1649
1722
|
*
|
|
1650
|
-
* ```
|
|
1723
|
+
* ```js
|
|
1651
1724
|
* const store = createStore().setTables({
|
|
1652
1725
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1653
1726
|
* });
|
|
@@ -1666,7 +1739,7 @@ export interface Store {
|
|
|
1666
1739
|
* This example registers a listener that responds to any changes to the whole
|
|
1667
1740
|
* Store, and which also mutates the Store itself.
|
|
1668
1741
|
*
|
|
1669
|
-
* ```
|
|
1742
|
+
* ```js
|
|
1670
1743
|
* const store = createStore().setTables({
|
|
1671
1744
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1672
1745
|
* });
|
|
@@ -1713,7 +1786,7 @@ export interface Store {
|
|
|
1713
1786
|
* This example registers a listener that responds to any change to the Table
|
|
1714
1787
|
* Ids.
|
|
1715
1788
|
*
|
|
1716
|
-
* ```
|
|
1789
|
+
* ```js
|
|
1717
1790
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1718
1791
|
* const listenerId = store.addTableIdsListener((store) => {
|
|
1719
1792
|
* console.log('Table Ids changed');
|
|
@@ -1730,7 +1803,7 @@ export interface Store {
|
|
|
1730
1803
|
* This example registers a listener that responds to any change to the Table
|
|
1731
1804
|
* Ids, and which also mutates the Store itself.
|
|
1732
1805
|
*
|
|
1733
|
-
* ```
|
|
1806
|
+
* ```js
|
|
1734
1807
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1735
1808
|
* const listenerId = store.addTableIdsListener(
|
|
1736
1809
|
* (store) => store.setCell('meta', 'update', 'store', true),
|
|
@@ -1743,6 +1816,7 @@ export interface Store {
|
|
|
1743
1816
|
*
|
|
1744
1817
|
* store.delListener(listenerId);
|
|
1745
1818
|
* ```
|
|
1819
|
+
* @category Listener
|
|
1746
1820
|
*/
|
|
1747
1821
|
addTableIdsListener(listener: TableIdsListener, mutator?: boolean): Id;
|
|
1748
1822
|
|
|
@@ -1778,7 +1852,7 @@ export interface Store {
|
|
|
1778
1852
|
* This example registers a listener that responds to any changes to a
|
|
1779
1853
|
* specific Table.
|
|
1780
1854
|
*
|
|
1781
|
-
* ```
|
|
1855
|
+
* ```js
|
|
1782
1856
|
* const store = createStore().setTables({
|
|
1783
1857
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1784
1858
|
* });
|
|
@@ -1800,7 +1874,7 @@ export interface Store {
|
|
|
1800
1874
|
* This example registers a listener that responds to any changes to any
|
|
1801
1875
|
* Table.
|
|
1802
1876
|
*
|
|
1803
|
-
* ```
|
|
1877
|
+
* ```js
|
|
1804
1878
|
* const store = createStore().setTables({
|
|
1805
1879
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1806
1880
|
* });
|
|
@@ -1819,7 +1893,7 @@ export interface Store {
|
|
|
1819
1893
|
* This example registers a listener that responds to any changes to a
|
|
1820
1894
|
* specific Table, and which also mutates the Store itself.
|
|
1821
1895
|
*
|
|
1822
|
-
* ```
|
|
1896
|
+
* ```js
|
|
1823
1897
|
* const store = createStore().setTables({
|
|
1824
1898
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1825
1899
|
* });
|
|
@@ -1875,7 +1949,7 @@ export interface Store {
|
|
|
1875
1949
|
* This example registers a listener that responds to any change to the Row
|
|
1876
1950
|
* Ids of a specific Table.
|
|
1877
1951
|
*
|
|
1878
|
-
* ```
|
|
1952
|
+
* ```js
|
|
1879
1953
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1880
1954
|
* const listenerId = store.addRowIdsListener('pets', (store) => {
|
|
1881
1955
|
* console.log('Row Ids for pets table changed');
|
|
@@ -1892,7 +1966,7 @@ export interface Store {
|
|
|
1892
1966
|
* This example registers a listener that responds to any change to the Row
|
|
1893
1967
|
* Ids of any Table.
|
|
1894
1968
|
*
|
|
1895
|
-
* ```
|
|
1969
|
+
* ```js
|
|
1896
1970
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1897
1971
|
* const listenerId = store.addRowIdsListener(null, (store, tableId) => {
|
|
1898
1972
|
* console.log(`Row Ids for ${tableId} table changed`);
|
|
@@ -1912,7 +1986,7 @@ export interface Store {
|
|
|
1912
1986
|
* This example registers a listener that responds to any change to the Row
|
|
1913
1987
|
* Ids of a specific Table, and which also mutates the Store itself.
|
|
1914
1988
|
*
|
|
1915
|
-
* ```
|
|
1989
|
+
* ```js
|
|
1916
1990
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1917
1991
|
* const listenerId = store.addRowIdsListener(
|
|
1918
1992
|
* 'pets',
|
|
@@ -1926,6 +2000,7 @@ export interface Store {
|
|
|
1926
2000
|
*
|
|
1927
2001
|
* store.delListener(listenerId);
|
|
1928
2002
|
* ```
|
|
2003
|
+
* @category Listener
|
|
1929
2004
|
*/
|
|
1930
2005
|
addRowIdsListener(
|
|
1931
2006
|
tableId: IdOrNull,
|
|
@@ -1971,7 +2046,7 @@ export interface Store {
|
|
|
1971
2046
|
* This example registers a listener that responds to any changes to a
|
|
1972
2047
|
* specific Row.
|
|
1973
2048
|
*
|
|
1974
|
-
* ```
|
|
2049
|
+
* ```js
|
|
1975
2050
|
* const store = createStore().setTables({
|
|
1976
2051
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1977
2052
|
* });
|
|
@@ -1993,7 +2068,7 @@ export interface Store {
|
|
|
1993
2068
|
* @example
|
|
1994
2069
|
* This example registers a listener that responds to any changes to any Row.
|
|
1995
2070
|
*
|
|
1996
|
-
* ```
|
|
2071
|
+
* ```js
|
|
1997
2072
|
* const store = createStore().setTables({
|
|
1998
2073
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1999
2074
|
* });
|
|
@@ -2016,7 +2091,7 @@ export interface Store {
|
|
|
2016
2091
|
* This example registers a listener that responds to any changes to a
|
|
2017
2092
|
* specific Row, and which also mutates the Store itself.
|
|
2018
2093
|
*
|
|
2019
|
-
* ```
|
|
2094
|
+
* ```js
|
|
2020
2095
|
* const store = createStore().setTables({
|
|
2021
2096
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2022
2097
|
* });
|
|
@@ -2083,7 +2158,7 @@ export interface Store {
|
|
|
2083
2158
|
* This example registers a listener that responds to any change to the Cell
|
|
2084
2159
|
* Ids of a specific Row.
|
|
2085
2160
|
*
|
|
2086
|
-
* ```
|
|
2161
|
+
* ```js
|
|
2087
2162
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
2088
2163
|
* const listenerId = store.addCellIdsListener('pets', 'fido', (store) => {
|
|
2089
2164
|
* console.log('Cell Ids for fido row in pets table changed');
|
|
@@ -2100,7 +2175,7 @@ export interface Store {
|
|
|
2100
2175
|
* This example registers a listener that responds to any change to the Cell
|
|
2101
2176
|
* Ids of any Row.
|
|
2102
2177
|
*
|
|
2103
|
-
* ```
|
|
2178
|
+
* ```js
|
|
2104
2179
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
2105
2180
|
* const listenerId = store.addCellIdsListener(
|
|
2106
2181
|
* null,
|
|
@@ -2124,7 +2199,7 @@ export interface Store {
|
|
|
2124
2199
|
* This example registers a listener that responds to any change to the Cell
|
|
2125
2200
|
* Ids of a specific Row, and which also mutates the Store itself.
|
|
2126
2201
|
*
|
|
2127
|
-
* ```
|
|
2202
|
+
* ```js
|
|
2128
2203
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
2129
2204
|
* const listenerId = store.addCellIdsListener(
|
|
2130
2205
|
* 'pets',
|
|
@@ -2140,6 +2215,7 @@ export interface Store {
|
|
|
2140
2215
|
*
|
|
2141
2216
|
* store.delListener(listenerId);
|
|
2142
2217
|
* ```
|
|
2218
|
+
* @category Listener
|
|
2143
2219
|
*/
|
|
2144
2220
|
addCellIdsListener(
|
|
2145
2221
|
tableId: IdOrNull,
|
|
@@ -2188,7 +2264,7 @@ export interface Store {
|
|
|
2188
2264
|
* This example registers a listener that responds to any changes to a
|
|
2189
2265
|
* specific Cell.
|
|
2190
2266
|
*
|
|
2191
|
-
* ```
|
|
2267
|
+
* ```js
|
|
2192
2268
|
* const store = createStore().setTables({
|
|
2193
2269
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2194
2270
|
* });
|
|
@@ -2213,7 +2289,7 @@ export interface Store {
|
|
|
2213
2289
|
* @example
|
|
2214
2290
|
* This example registers a listener that responds to any changes to any Cell.
|
|
2215
2291
|
*
|
|
2216
|
-
* ```
|
|
2292
|
+
* ```js
|
|
2217
2293
|
* const store = createStore().setTables({
|
|
2218
2294
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2219
2295
|
* });
|
|
@@ -2239,7 +2315,7 @@ export interface Store {
|
|
|
2239
2315
|
* This example registers a listener that responds to any changes to a
|
|
2240
2316
|
* specific Cell, and which also mutates the Store itself.
|
|
2241
2317
|
*
|
|
2242
|
-
* ```
|
|
2318
|
+
* ```js
|
|
2243
2319
|
* const store = createStore().setTables({
|
|
2244
2320
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2245
2321
|
* });
|
|
@@ -2283,7 +2359,7 @@ export interface Store {
|
|
|
2283
2359
|
* valid values. After that list changes, the listener is called to apply the
|
|
2284
2360
|
* condition to the existing data.
|
|
2285
2361
|
*
|
|
2286
|
-
* ```
|
|
2362
|
+
* ```js
|
|
2287
2363
|
* const validColors = ['walnut', 'brown', 'black'];
|
|
2288
2364
|
* const store = createStore();
|
|
2289
2365
|
* const listenerId = store.addCellListener(
|
|
@@ -2328,7 +2404,7 @@ export interface Store {
|
|
|
2328
2404
|
* @example
|
|
2329
2405
|
* This example registers a listener and then removes it.
|
|
2330
2406
|
*
|
|
2331
|
-
* ```
|
|
2407
|
+
* ```js
|
|
2332
2408
|
* const store = createStore().setTables({
|
|
2333
2409
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2334
2410
|
* });
|
|
@@ -2365,7 +2441,7 @@ export interface Store {
|
|
|
2365
2441
|
* @example
|
|
2366
2442
|
* This example gets the listener statistics of a small and simple Store.
|
|
2367
2443
|
*
|
|
2368
|
-
* ```
|
|
2444
|
+
* ```js
|
|
2369
2445
|
* const store = createStore();
|
|
2370
2446
|
* store.addTablesListener(() => console.log('Tables changed'));
|
|
2371
2447
|
* store.addRowIdsListener(() => console.log('Row Ids changed'));
|
|
@@ -2392,7 +2468,7 @@ export interface Store {
|
|
|
2392
2468
|
* @example
|
|
2393
2469
|
* This example creates a Store.
|
|
2394
2470
|
*
|
|
2395
|
-
* ```
|
|
2471
|
+
* ```js
|
|
2396
2472
|
* const store = createStore();
|
|
2397
2473
|
* console.log(store.getTables());
|
|
2398
2474
|
* // -> {}
|
|
@@ -2400,7 +2476,7 @@ export interface Store {
|
|
|
2400
2476
|
* @example
|
|
2401
2477
|
* This example creates a Store with some initial data:
|
|
2402
2478
|
*
|
|
2403
|
-
* ```
|
|
2479
|
+
* ```js
|
|
2404
2480
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
2405
2481
|
* console.log(store.getTables());
|
|
2406
2482
|
* // -> {pets: {fido: {species: 'dog'}}}
|
|
@@ -2408,7 +2484,7 @@ export interface Store {
|
|
|
2408
2484
|
* @example
|
|
2409
2485
|
* This example creates a Store with some initial data and a Schema:
|
|
2410
2486
|
*
|
|
2411
|
-
* ```
|
|
2487
|
+
* ```js
|
|
2412
2488
|
* const store = createStore()
|
|
2413
2489
|
* .setTables({pets: {fido: {species: 'dog'}}})
|
|
2414
2490
|
* .setSchema({
|
|
@@ -2420,5 +2496,6 @@ export interface Store {
|
|
|
2420
2496
|
* console.log(store.getTables());
|
|
2421
2497
|
* // -> {pets: {fido: {species: 'dog', sold: false}}}
|
|
2422
2498
|
* ```
|
|
2499
|
+
* @category Creation
|
|
2423
2500
|
*/
|
|
2424
2501
|
export function createStore(): Store;
|