tinybase 0.9.1 → 1.0.0
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 +38 -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 +38 -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 +39 -76
- package/lib/debug/indexes.js +18 -10
- package/lib/debug/metrics.d.ts +49 -20
- package/lib/debug/metrics.js +1 -1
- package/lib/debug/persisters.d.ts +207 -17
- package/lib/debug/persisters.js +1 -1
- package/lib/debug/relationships.d.ts +48 -23
- package/lib/debug/relationships.js +1 -1
- package/lib/debug/store.d.ts +184 -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} +270 -162
- package/lib/debug/{react.js → ui-react.js} +28 -19
- package/lib/indexes.d.ts +39 -76
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.d.ts +49 -20
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/persisters.d.ts +207 -17
- package/lib/persisters.js +1 -1
- package/lib/persisters.js.gz +0 -0
- package/lib/relationships.d.ts +48 -23
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.d.ts +184 -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} +270 -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 +28 -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/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,11 @@ export type StoreListenerStats = {
|
|
|
539
612
|
*
|
|
540
613
|
* store.delListener(listenerId);
|
|
541
614
|
* ```
|
|
615
|
+
* @see The Basics guides
|
|
616
|
+
* @see Using Schemas guides
|
|
617
|
+
* @see Hello World demos
|
|
618
|
+
* @see Todo App demos
|
|
619
|
+
* @category Store
|
|
542
620
|
*/
|
|
543
621
|
export interface Store {
|
|
544
622
|
/**
|
|
@@ -553,7 +631,7 @@ export interface Store {
|
|
|
553
631
|
* @example
|
|
554
632
|
* This example retrieves the data in a Store.
|
|
555
633
|
*
|
|
556
|
-
* ```
|
|
634
|
+
* ```js
|
|
557
635
|
* const store = createStore().setTables({
|
|
558
636
|
* pets: {fido: {species: 'dog'}},
|
|
559
637
|
* species: {dog: {price: 5}},
|
|
@@ -565,7 +643,7 @@ export interface Store {
|
|
|
565
643
|
* This example retrieves the Tables of an empty Store, returning an empty
|
|
566
644
|
* object.
|
|
567
645
|
*
|
|
568
|
-
* ```
|
|
646
|
+
* ```js
|
|
569
647
|
* const store = createStore();
|
|
570
648
|
* console.log(store.getTables());
|
|
571
649
|
* // -> {}
|
|
@@ -590,7 +668,7 @@ export interface Store {
|
|
|
590
668
|
* @example
|
|
591
669
|
* This example retrieves the Table Ids in a Store.
|
|
592
670
|
*
|
|
593
|
-
* ```
|
|
671
|
+
* ```js
|
|
594
672
|
* const store = createStore().setTables({
|
|
595
673
|
* pets: {fido: {species: 'dog'}},
|
|
596
674
|
* species: {dog: {price: 5}},
|
|
@@ -602,7 +680,7 @@ export interface Store {
|
|
|
602
680
|
* This example retrieves the Table Ids of an empty Store, returning an empty
|
|
603
681
|
* array.
|
|
604
682
|
*
|
|
605
|
-
* ```
|
|
683
|
+
* ```js
|
|
606
684
|
* const store = createStore();
|
|
607
685
|
* console.log(store.getTableIds());
|
|
608
686
|
* // -> []
|
|
@@ -624,7 +702,7 @@ export interface Store {
|
|
|
624
702
|
* @example
|
|
625
703
|
* This example retrieves the data in a single Table.
|
|
626
704
|
*
|
|
627
|
-
* ```
|
|
705
|
+
* ```js
|
|
628
706
|
* const store = createStore().setTables({
|
|
629
707
|
* pets: {fido: {species: 'dog'}},
|
|
630
708
|
* species: {dog: {price: 5}},
|
|
@@ -636,7 +714,7 @@ export interface Store {
|
|
|
636
714
|
* This example retrieves a Table that does not exist, returning an empty
|
|
637
715
|
* object.
|
|
638
716
|
*
|
|
639
|
-
* ```
|
|
717
|
+
* ```js
|
|
640
718
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
641
719
|
* console.log(store.getTable('employees'));
|
|
642
720
|
* // -> {}
|
|
@@ -658,7 +736,7 @@ export interface Store {
|
|
|
658
736
|
* @example
|
|
659
737
|
* This example retrieves the Row Ids in a Table.
|
|
660
738
|
*
|
|
661
|
-
* ```
|
|
739
|
+
* ```js
|
|
662
740
|
* const store = createStore().setTables({
|
|
663
741
|
* pets: {
|
|
664
742
|
* fido: {species: 'dog'},
|
|
@@ -672,7 +750,7 @@ export interface Store {
|
|
|
672
750
|
* This example retrieves the Row Ids of a Table that does not exist,
|
|
673
751
|
* returning an empty array.
|
|
674
752
|
*
|
|
675
|
-
* ```
|
|
753
|
+
* ```js
|
|
676
754
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
677
755
|
* console.log(store.getRowIds('employees'));
|
|
678
756
|
* // -> []
|
|
@@ -695,7 +773,7 @@ export interface Store {
|
|
|
695
773
|
* @example
|
|
696
774
|
* This example retrieves the data in a single Row.
|
|
697
775
|
*
|
|
698
|
-
* ```
|
|
776
|
+
* ```js
|
|
699
777
|
* const store = createStore().setTables({
|
|
700
778
|
* pets: {
|
|
701
779
|
* fido: {species: 'dog'},
|
|
@@ -709,7 +787,7 @@ export interface Store {
|
|
|
709
787
|
* This example retrieves a Row that does not exist, returning an empty
|
|
710
788
|
* object.
|
|
711
789
|
*
|
|
712
|
-
* ```
|
|
790
|
+
* ```js
|
|
713
791
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
714
792
|
* console.log(store.getRow('pets', 'felix'));
|
|
715
793
|
* // -> {}
|
|
@@ -733,7 +811,7 @@ export interface Store {
|
|
|
733
811
|
* @example
|
|
734
812
|
* This example retrieves the Cell Ids in a Row.
|
|
735
813
|
*
|
|
736
|
-
* ```
|
|
814
|
+
* ```js
|
|
737
815
|
* const store = createStore().setTables({
|
|
738
816
|
* pets: {
|
|
739
817
|
* fido: {species: 'dog', color: 'brown'},
|
|
@@ -746,7 +824,7 @@ export interface Store {
|
|
|
746
824
|
* This example retrieves the Cell Ids of a Cell that does not exist,
|
|
747
825
|
* returning an empty array.
|
|
748
826
|
*
|
|
749
|
-
* ```
|
|
827
|
+
* ```js
|
|
750
828
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
751
829
|
* console.log(store.getCellIds('pets', 'felix'));
|
|
752
830
|
* // -> []
|
|
@@ -770,7 +848,7 @@ export interface Store {
|
|
|
770
848
|
* @example
|
|
771
849
|
* This example retrieves a single Cell.
|
|
772
850
|
*
|
|
773
|
-
* ```
|
|
851
|
+
* ```js
|
|
774
852
|
* const store = createStore().setTables({
|
|
775
853
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
776
854
|
* });
|
|
@@ -780,7 +858,7 @@ export interface Store {
|
|
|
780
858
|
* @example
|
|
781
859
|
* This example retrieves a Cell that does not exist, returning `undefined`.
|
|
782
860
|
*
|
|
783
|
-
* ```
|
|
861
|
+
* ```js
|
|
784
862
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
785
863
|
* console.log(store.getCell('pets', 'fido', 'color'));
|
|
786
864
|
* // -> undefined
|
|
@@ -798,7 +876,7 @@ export interface Store {
|
|
|
798
876
|
* @example
|
|
799
877
|
* This example shows two simple Table existence checks.
|
|
800
878
|
*
|
|
801
|
-
* ```
|
|
879
|
+
* ```js
|
|
802
880
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
803
881
|
* console.log(store.hasTable('pets'));
|
|
804
882
|
* // -> true
|
|
@@ -819,7 +897,7 @@ export interface Store {
|
|
|
819
897
|
* @example
|
|
820
898
|
* This example shows two simple Row existence checks.
|
|
821
899
|
*
|
|
822
|
-
* ```
|
|
900
|
+
* ```js
|
|
823
901
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
824
902
|
* console.log(store.hasRow('pets', 'fido'));
|
|
825
903
|
* // -> true
|
|
@@ -841,7 +919,7 @@ export interface Store {
|
|
|
841
919
|
* @example
|
|
842
920
|
* This example shows two simple Cell existence checks.
|
|
843
921
|
*
|
|
844
|
-
* ```
|
|
922
|
+
* ```js
|
|
845
923
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
846
924
|
* console.log(store.hasCell('pets', 'fido', 'species'));
|
|
847
925
|
* // -> true
|
|
@@ -860,7 +938,7 @@ export interface Store {
|
|
|
860
938
|
* @example
|
|
861
939
|
* This example serializes the contents of a Store.
|
|
862
940
|
*
|
|
863
|
-
* ```
|
|
941
|
+
* ```js
|
|
864
942
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
865
943
|
* console.log(store.getJson());
|
|
866
944
|
* // -> '{"pets":{"fido":{"species":"dog"}}}'
|
|
@@ -868,7 +946,7 @@ export interface Store {
|
|
|
868
946
|
* @example
|
|
869
947
|
* This example serializes the contents of an empty Store.
|
|
870
948
|
*
|
|
871
|
-
* ```
|
|
949
|
+
* ```js
|
|
872
950
|
* const store = createStore();
|
|
873
951
|
* console.log(store.getJson());
|
|
874
952
|
* // -> '{}'
|
|
@@ -889,7 +967,7 @@ export interface Store {
|
|
|
889
967
|
* @example
|
|
890
968
|
* This example serializes the Schema of a Store.
|
|
891
969
|
*
|
|
892
|
-
* ```
|
|
970
|
+
* ```js
|
|
893
971
|
* const store = createStore().setSchema({
|
|
894
972
|
* pets: {
|
|
895
973
|
* species: {type: 'string'},
|
|
@@ -902,7 +980,7 @@ export interface Store {
|
|
|
902
980
|
* @example
|
|
903
981
|
* This example serializes the Schema of an empty Store.
|
|
904
982
|
*
|
|
905
|
-
* ```
|
|
983
|
+
* ```js
|
|
906
984
|
* const store = createStore();
|
|
907
985
|
* console.log(store.getSchemaJson());
|
|
908
986
|
* // -> '{}'
|
|
@@ -932,7 +1010,7 @@ export interface Store {
|
|
|
932
1010
|
* @example
|
|
933
1011
|
* This example sets the data of a Store.
|
|
934
1012
|
*
|
|
935
|
-
* ```
|
|
1013
|
+
* ```js
|
|
936
1014
|
* const store = createStore().setTables({
|
|
937
1015
|
* pets: {fido: {species: 'dog'}},
|
|
938
1016
|
* species: {dog: {price: 5}},
|
|
@@ -944,7 +1022,7 @@ export interface Store {
|
|
|
944
1022
|
* This example attempts to set the data of an existing Store with partly
|
|
945
1023
|
* invalid, and then completely invalid, Tables objects.
|
|
946
1024
|
*
|
|
947
|
-
* ```
|
|
1025
|
+
* ```js
|
|
948
1026
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
949
1027
|
*
|
|
950
1028
|
* store.setTables({pets: {felix: {species: 'cat', bug: []}}});
|
|
@@ -983,7 +1061,7 @@ export interface Store {
|
|
|
983
1061
|
* @example
|
|
984
1062
|
* This example sets the data of a single Table.
|
|
985
1063
|
*
|
|
986
|
-
* ```
|
|
1064
|
+
* ```js
|
|
987
1065
|
* const store = createStore().setTable('pets', {
|
|
988
1066
|
* fido: {species: 'dog'},
|
|
989
1067
|
* felix: {species: 'cat'},
|
|
@@ -995,7 +1073,7 @@ export interface Store {
|
|
|
995
1073
|
* This example attempts to set the data of an existing Store with partly
|
|
996
1074
|
* invalid, and then completely invalid, Table objects.
|
|
997
1075
|
*
|
|
998
|
-
* ```
|
|
1076
|
+
* ```js
|
|
999
1077
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1000
1078
|
*
|
|
1001
1079
|
* store.setTable('pets', {felix: {species: 'cat', bug: []}});
|
|
@@ -1036,7 +1114,7 @@ export interface Store {
|
|
|
1036
1114
|
* @example
|
|
1037
1115
|
* This example sets the data of a single Row.
|
|
1038
1116
|
*
|
|
1039
|
-
* ```
|
|
1117
|
+
* ```js
|
|
1040
1118
|
* const store = createStore().setRow('pets', 'fido', {species: 'dog'});
|
|
1041
1119
|
* console.log(store.getTables());
|
|
1042
1120
|
* // -> {pets: {fido: {species: 'dog'}}}
|
|
@@ -1045,7 +1123,7 @@ export interface Store {
|
|
|
1045
1123
|
* This example attempts to set the data of an existing Store with partly
|
|
1046
1124
|
* invalid, and then completely invalid, Row objects.
|
|
1047
1125
|
*
|
|
1048
|
-
* ```
|
|
1126
|
+
* ```js
|
|
1049
1127
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1050
1128
|
*
|
|
1051
1129
|
* store.setRow('pets', 'fido', {color: 'brown', bug: []});
|
|
@@ -1085,7 +1163,7 @@ export interface Store {
|
|
|
1085
1163
|
* @example
|
|
1086
1164
|
* This example adds a single Row.
|
|
1087
1165
|
*
|
|
1088
|
-
* ```
|
|
1166
|
+
* ```js
|
|
1089
1167
|
* const store = createStore();
|
|
1090
1168
|
* console.log(store.addRow('pets', {species: 'dog'}));
|
|
1091
1169
|
* // -> '0'
|
|
@@ -1096,7 +1174,7 @@ export interface Store {
|
|
|
1096
1174
|
* This example attempts to add Rows to an existing Store with partly invalid,
|
|
1097
1175
|
* and then completely invalid, Row objects.
|
|
1098
1176
|
*
|
|
1099
|
-
* ```
|
|
1177
|
+
* ```js
|
|
1100
1178
|
* const store = createStore().setTables({pets: {'0': {species: 'dog'}}});
|
|
1101
1179
|
*
|
|
1102
1180
|
* console.log(store.addRow('pets', {species: 'cat', bug: []}));
|
|
@@ -1138,7 +1216,7 @@ export interface Store {
|
|
|
1138
1216
|
* @example
|
|
1139
1217
|
* This example sets some of the data of a single Row.
|
|
1140
1218
|
*
|
|
1141
|
-
* ```
|
|
1219
|
+
* ```js
|
|
1142
1220
|
* const store = createStore().setTables({
|
|
1143
1221
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1144
1222
|
* });
|
|
@@ -1150,7 +1228,7 @@ export interface Store {
|
|
|
1150
1228
|
* This example attempts to set some of the data of an existing Store with
|
|
1151
1229
|
* partly invalid, and then completely invalid, Row objects.
|
|
1152
1230
|
*
|
|
1153
|
-
* ```
|
|
1231
|
+
* ```js
|
|
1154
1232
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1155
1233
|
*
|
|
1156
1234
|
* store.setPartialRow('pets', 'fido', {color: 'brown', bug: []});
|
|
@@ -1192,7 +1270,7 @@ export interface Store {
|
|
|
1192
1270
|
* @example
|
|
1193
1271
|
* This example sets the value of a single Cell.
|
|
1194
1272
|
*
|
|
1195
|
-
* ```
|
|
1273
|
+
* ```js
|
|
1196
1274
|
* const store = createStore().setCell('pets', 'fido', 'species', 'dog');
|
|
1197
1275
|
* console.log(store.getTables());
|
|
1198
1276
|
* // -> {pets: {fido: {species: 'dog'}}}
|
|
@@ -1200,7 +1278,7 @@ export interface Store {
|
|
|
1200
1278
|
* @example
|
|
1201
1279
|
* This example sets the data of a single Cell by mapping the existing value.
|
|
1202
1280
|
*
|
|
1203
|
-
* ```
|
|
1281
|
+
* ```js
|
|
1204
1282
|
* const increment = (cell) => cell + 1;
|
|
1205
1283
|
* const store = createStore().setTables({pets: {fido: {visits: 1}}});
|
|
1206
1284
|
*
|
|
@@ -1212,7 +1290,7 @@ export interface Store {
|
|
|
1212
1290
|
* This example attempts to set the data of an existing Store with an invalid
|
|
1213
1291
|
* Cell value.
|
|
1214
1292
|
*
|
|
1215
|
-
* ```
|
|
1293
|
+
* ```js
|
|
1216
1294
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1217
1295
|
*
|
|
1218
1296
|
* store.setCell('pets', 'fido', 'bug', []);
|
|
@@ -1237,7 +1315,7 @@ export interface Store {
|
|
|
1237
1315
|
* @example
|
|
1238
1316
|
* This example sets the contents of a Store from a serialization.
|
|
1239
1317
|
*
|
|
1240
|
-
* ```
|
|
1318
|
+
* ```js
|
|
1241
1319
|
* const store = createStore();
|
|
1242
1320
|
* store.setJson('{"pets":{"fido":{"species":"dog"}}}');
|
|
1243
1321
|
* console.log(store.getTables());
|
|
@@ -1247,7 +1325,7 @@ export interface Store {
|
|
|
1247
1325
|
* This example attempts to set the contents of a Store from an invalid
|
|
1248
1326
|
* serialization.
|
|
1249
1327
|
*
|
|
1250
|
-
* ```
|
|
1328
|
+
* ```js
|
|
1251
1329
|
* const store = createStore();
|
|
1252
1330
|
* store.setJson('{"pets":{"fido":{');
|
|
1253
1331
|
* console.log(store.getTables());
|
|
@@ -1264,16 +1342,15 @@ export interface Store {
|
|
|
1264
1342
|
* applied or as invalid Table, Row, or Cell objects are removed. These
|
|
1265
1343
|
* changes will fire any listeners to that data, as expected.
|
|
1266
1344
|
*
|
|
1267
|
-
*
|
|
1268
|
-
*
|
|
1269
|
-
* completely remove an existing Schema with the delSchema method.
|
|
1345
|
+
* When no longer needed, you can also completely remove an existing Schema
|
|
1346
|
+
* with the delSchema method.
|
|
1270
1347
|
*
|
|
1271
1348
|
* @param schema The Schema to be set for the Store.
|
|
1272
1349
|
* @returns A reference to the Store.
|
|
1273
1350
|
* @example
|
|
1274
1351
|
* This example sets the Schema of a Store after it has been created.
|
|
1275
1352
|
*
|
|
1276
|
-
* ```
|
|
1353
|
+
* ```js
|
|
1277
1354
|
* const store = createStore().setSchema({
|
|
1278
1355
|
* pets: {
|
|
1279
1356
|
* species: {type: 'string'},
|
|
@@ -1295,7 +1372,7 @@ export interface Store {
|
|
|
1295
1372
|
* @example
|
|
1296
1373
|
* This example removes the data of a Store.
|
|
1297
1374
|
*
|
|
1298
|
-
* ```
|
|
1375
|
+
* ```js
|
|
1299
1376
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1300
1377
|
*
|
|
1301
1378
|
* store.delTables();
|
|
@@ -1314,7 +1391,7 @@ export interface Store {
|
|
|
1314
1391
|
* @example
|
|
1315
1392
|
* This example removes a Table from a Store.
|
|
1316
1393
|
*
|
|
1317
|
-
* ```
|
|
1394
|
+
* ```js
|
|
1318
1395
|
* const store = createStore().setTables({
|
|
1319
1396
|
* pets: {fido: {species: 'dog'}},
|
|
1320
1397
|
* species: {dog: {price: 5}},
|
|
@@ -1339,7 +1416,7 @@ export interface Store {
|
|
|
1339
1416
|
* @example
|
|
1340
1417
|
* This example removes a Row from a Table.
|
|
1341
1418
|
*
|
|
1342
|
-
* ```
|
|
1419
|
+
* ```js
|
|
1343
1420
|
* const store = createStore().setTables({
|
|
1344
1421
|
* pets: {fido: {species: 'dog'}, felix: {species: 'cat'}},
|
|
1345
1422
|
* });
|
|
@@ -1382,7 +1459,7 @@ export interface Store {
|
|
|
1382
1459
|
* @example
|
|
1383
1460
|
* This example removes a Cell from a Row without a Schema.
|
|
1384
1461
|
*
|
|
1385
|
-
* ```
|
|
1462
|
+
* ```js
|
|
1386
1463
|
* const store = createStore().setTables({
|
|
1387
1464
|
* pets: {fido: {species: 'dog', sold: true}},
|
|
1388
1465
|
* });
|
|
@@ -1395,7 +1472,7 @@ export interface Store {
|
|
|
1395
1472
|
* This example removes a Cell from a Row with a Schema that defaults its
|
|
1396
1473
|
* value.
|
|
1397
1474
|
*
|
|
1398
|
-
* ```
|
|
1475
|
+
* ```js
|
|
1399
1476
|
* const store = createStore()
|
|
1400
1477
|
* .setTables({
|
|
1401
1478
|
* pets: {fido: {species: 'dog', sold: true}},
|
|
@@ -1415,7 +1492,7 @@ export interface Store {
|
|
|
1415
1492
|
* This example removes a Cell from a Row with a Schema that defaults its
|
|
1416
1493
|
* value, but uses the `forceDel` parameter to override it.
|
|
1417
1494
|
*
|
|
1418
|
-
* ```
|
|
1495
|
+
* ```js
|
|
1419
1496
|
* const store = createStore()
|
|
1420
1497
|
* .setTables({
|
|
1421
1498
|
* pets: {fido: {species: 'dog', sold: true}, felix: {species: 'cat'}},
|
|
@@ -1442,7 +1519,7 @@ export interface Store {
|
|
|
1442
1519
|
* @example
|
|
1443
1520
|
* This example removes the Schema of a Store.
|
|
1444
1521
|
*
|
|
1445
|
-
* ```
|
|
1522
|
+
* ```js
|
|
1446
1523
|
* const store = createStore().setSchema({pets: {species: {type: 'string'}}});
|
|
1447
1524
|
* store.delSchema();
|
|
1448
1525
|
* console.log(store.getSchemaJson());
|
|
@@ -1481,7 +1558,7 @@ export interface Store {
|
|
|
1481
1558
|
* within, a transaction. In the second case, the Row listener is only called
|
|
1482
1559
|
* once.
|
|
1483
1560
|
*
|
|
1484
|
-
* ```
|
|
1561
|
+
* ```js
|
|
1485
1562
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1486
1563
|
* store.addRowListener('pets', 'fido', () => console.log('Fido changed'));
|
|
1487
1564
|
*
|
|
@@ -1501,7 +1578,7 @@ export interface Store {
|
|
|
1501
1578
|
* called once - and with the final value - only if there is a net overall
|
|
1502
1579
|
* change.
|
|
1503
1580
|
*
|
|
1504
|
-
* ```
|
|
1581
|
+
* ```js
|
|
1505
1582
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1506
1583
|
* store.addCellListener(
|
|
1507
1584
|
* 'pets',
|
|
@@ -1543,7 +1620,7 @@ export interface Store {
|
|
|
1543
1620
|
* This example iterates over each Table in a Store, and lists each Row Id
|
|
1544
1621
|
* within them.
|
|
1545
1622
|
*
|
|
1546
|
-
* ```
|
|
1623
|
+
* ```js
|
|
1547
1624
|
* const store = createStore().setTables({
|
|
1548
1625
|
* pets: {fido: {species: 'dog'}},
|
|
1549
1626
|
* species: {dog: {price: 5}},
|
|
@@ -1575,7 +1652,7 @@ export interface Store {
|
|
|
1575
1652
|
* This example iterates over each Row in a Table, and lists each Cell Id
|
|
1576
1653
|
* within them.
|
|
1577
1654
|
*
|
|
1578
|
-
* ```
|
|
1655
|
+
* ```js
|
|
1579
1656
|
* const store = createStore().setTables({
|
|
1580
1657
|
* pets: {
|
|
1581
1658
|
* fido: {species: 'dog'},
|
|
@@ -1607,7 +1684,7 @@ export interface Store {
|
|
|
1607
1684
|
* @example
|
|
1608
1685
|
* This example iterates over each Cell in a Row, and lists its value.
|
|
1609
1686
|
*
|
|
1610
|
-
* ```
|
|
1687
|
+
* ```js
|
|
1611
1688
|
* const store = createStore().setTables({
|
|
1612
1689
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1613
1690
|
* });
|
|
@@ -1647,7 +1724,7 @@ export interface Store {
|
|
|
1647
1724
|
* This example registers a listener that responds to any changes to the whole
|
|
1648
1725
|
* Store.
|
|
1649
1726
|
*
|
|
1650
|
-
* ```
|
|
1727
|
+
* ```js
|
|
1651
1728
|
* const store = createStore().setTables({
|
|
1652
1729
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1653
1730
|
* });
|
|
@@ -1666,7 +1743,7 @@ export interface Store {
|
|
|
1666
1743
|
* This example registers a listener that responds to any changes to the whole
|
|
1667
1744
|
* Store, and which also mutates the Store itself.
|
|
1668
1745
|
*
|
|
1669
|
-
* ```
|
|
1746
|
+
* ```js
|
|
1670
1747
|
* const store = createStore().setTables({
|
|
1671
1748
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1672
1749
|
* });
|
|
@@ -1713,7 +1790,7 @@ export interface Store {
|
|
|
1713
1790
|
* This example registers a listener that responds to any change to the Table
|
|
1714
1791
|
* Ids.
|
|
1715
1792
|
*
|
|
1716
|
-
* ```
|
|
1793
|
+
* ```js
|
|
1717
1794
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1718
1795
|
* const listenerId = store.addTableIdsListener((store) => {
|
|
1719
1796
|
* console.log('Table Ids changed');
|
|
@@ -1730,7 +1807,7 @@ export interface Store {
|
|
|
1730
1807
|
* This example registers a listener that responds to any change to the Table
|
|
1731
1808
|
* Ids, and which also mutates the Store itself.
|
|
1732
1809
|
*
|
|
1733
|
-
* ```
|
|
1810
|
+
* ```js
|
|
1734
1811
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1735
1812
|
* const listenerId = store.addTableIdsListener(
|
|
1736
1813
|
* (store) => store.setCell('meta', 'update', 'store', true),
|
|
@@ -1743,6 +1820,7 @@ export interface Store {
|
|
|
1743
1820
|
*
|
|
1744
1821
|
* store.delListener(listenerId);
|
|
1745
1822
|
* ```
|
|
1823
|
+
* @category Listener
|
|
1746
1824
|
*/
|
|
1747
1825
|
addTableIdsListener(listener: TableIdsListener, mutator?: boolean): Id;
|
|
1748
1826
|
|
|
@@ -1778,7 +1856,7 @@ export interface Store {
|
|
|
1778
1856
|
* This example registers a listener that responds to any changes to a
|
|
1779
1857
|
* specific Table.
|
|
1780
1858
|
*
|
|
1781
|
-
* ```
|
|
1859
|
+
* ```js
|
|
1782
1860
|
* const store = createStore().setTables({
|
|
1783
1861
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1784
1862
|
* });
|
|
@@ -1800,7 +1878,7 @@ export interface Store {
|
|
|
1800
1878
|
* This example registers a listener that responds to any changes to any
|
|
1801
1879
|
* Table.
|
|
1802
1880
|
*
|
|
1803
|
-
* ```
|
|
1881
|
+
* ```js
|
|
1804
1882
|
* const store = createStore().setTables({
|
|
1805
1883
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1806
1884
|
* });
|
|
@@ -1819,7 +1897,7 @@ export interface Store {
|
|
|
1819
1897
|
* This example registers a listener that responds to any changes to a
|
|
1820
1898
|
* specific Table, and which also mutates the Store itself.
|
|
1821
1899
|
*
|
|
1822
|
-
* ```
|
|
1900
|
+
* ```js
|
|
1823
1901
|
* const store = createStore().setTables({
|
|
1824
1902
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1825
1903
|
* });
|
|
@@ -1875,7 +1953,7 @@ export interface Store {
|
|
|
1875
1953
|
* This example registers a listener that responds to any change to the Row
|
|
1876
1954
|
* Ids of a specific Table.
|
|
1877
1955
|
*
|
|
1878
|
-
* ```
|
|
1956
|
+
* ```js
|
|
1879
1957
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1880
1958
|
* const listenerId = store.addRowIdsListener('pets', (store) => {
|
|
1881
1959
|
* console.log('Row Ids for pets table changed');
|
|
@@ -1892,7 +1970,7 @@ export interface Store {
|
|
|
1892
1970
|
* This example registers a listener that responds to any change to the Row
|
|
1893
1971
|
* Ids of any Table.
|
|
1894
1972
|
*
|
|
1895
|
-
* ```
|
|
1973
|
+
* ```js
|
|
1896
1974
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1897
1975
|
* const listenerId = store.addRowIdsListener(null, (store, tableId) => {
|
|
1898
1976
|
* console.log(`Row Ids for ${tableId} table changed`);
|
|
@@ -1912,7 +1990,7 @@ export interface Store {
|
|
|
1912
1990
|
* This example registers a listener that responds to any change to the Row
|
|
1913
1991
|
* Ids of a specific Table, and which also mutates the Store itself.
|
|
1914
1992
|
*
|
|
1915
|
-
* ```
|
|
1993
|
+
* ```js
|
|
1916
1994
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
1917
1995
|
* const listenerId = store.addRowIdsListener(
|
|
1918
1996
|
* 'pets',
|
|
@@ -1926,6 +2004,7 @@ export interface Store {
|
|
|
1926
2004
|
*
|
|
1927
2005
|
* store.delListener(listenerId);
|
|
1928
2006
|
* ```
|
|
2007
|
+
* @category Listener
|
|
1929
2008
|
*/
|
|
1930
2009
|
addRowIdsListener(
|
|
1931
2010
|
tableId: IdOrNull,
|
|
@@ -1971,7 +2050,7 @@ export interface Store {
|
|
|
1971
2050
|
* This example registers a listener that responds to any changes to a
|
|
1972
2051
|
* specific Row.
|
|
1973
2052
|
*
|
|
1974
|
-
* ```
|
|
2053
|
+
* ```js
|
|
1975
2054
|
* const store = createStore().setTables({
|
|
1976
2055
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1977
2056
|
* });
|
|
@@ -1993,7 +2072,7 @@ export interface Store {
|
|
|
1993
2072
|
* @example
|
|
1994
2073
|
* This example registers a listener that responds to any changes to any Row.
|
|
1995
2074
|
*
|
|
1996
|
-
* ```
|
|
2075
|
+
* ```js
|
|
1997
2076
|
* const store = createStore().setTables({
|
|
1998
2077
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
1999
2078
|
* });
|
|
@@ -2016,7 +2095,7 @@ export interface Store {
|
|
|
2016
2095
|
* This example registers a listener that responds to any changes to a
|
|
2017
2096
|
* specific Row, and which also mutates the Store itself.
|
|
2018
2097
|
*
|
|
2019
|
-
* ```
|
|
2098
|
+
* ```js
|
|
2020
2099
|
* const store = createStore().setTables({
|
|
2021
2100
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2022
2101
|
* });
|
|
@@ -2083,7 +2162,7 @@ export interface Store {
|
|
|
2083
2162
|
* This example registers a listener that responds to any change to the Cell
|
|
2084
2163
|
* Ids of a specific Row.
|
|
2085
2164
|
*
|
|
2086
|
-
* ```
|
|
2165
|
+
* ```js
|
|
2087
2166
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
2088
2167
|
* const listenerId = store.addCellIdsListener('pets', 'fido', (store) => {
|
|
2089
2168
|
* console.log('Cell Ids for fido row in pets table changed');
|
|
@@ -2100,7 +2179,7 @@ export interface Store {
|
|
|
2100
2179
|
* This example registers a listener that responds to any change to the Cell
|
|
2101
2180
|
* Ids of any Row.
|
|
2102
2181
|
*
|
|
2103
|
-
* ```
|
|
2182
|
+
* ```js
|
|
2104
2183
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
2105
2184
|
* const listenerId = store.addCellIdsListener(
|
|
2106
2185
|
* null,
|
|
@@ -2124,7 +2203,7 @@ export interface Store {
|
|
|
2124
2203
|
* This example registers a listener that responds to any change to the Cell
|
|
2125
2204
|
* Ids of a specific Row, and which also mutates the Store itself.
|
|
2126
2205
|
*
|
|
2127
|
-
* ```
|
|
2206
|
+
* ```js
|
|
2128
2207
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
2129
2208
|
* const listenerId = store.addCellIdsListener(
|
|
2130
2209
|
* 'pets',
|
|
@@ -2140,6 +2219,7 @@ export interface Store {
|
|
|
2140
2219
|
*
|
|
2141
2220
|
* store.delListener(listenerId);
|
|
2142
2221
|
* ```
|
|
2222
|
+
* @category Listener
|
|
2143
2223
|
*/
|
|
2144
2224
|
addCellIdsListener(
|
|
2145
2225
|
tableId: IdOrNull,
|
|
@@ -2188,7 +2268,7 @@ export interface Store {
|
|
|
2188
2268
|
* This example registers a listener that responds to any changes to a
|
|
2189
2269
|
* specific Cell.
|
|
2190
2270
|
*
|
|
2191
|
-
* ```
|
|
2271
|
+
* ```js
|
|
2192
2272
|
* const store = createStore().setTables({
|
|
2193
2273
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2194
2274
|
* });
|
|
@@ -2213,7 +2293,7 @@ export interface Store {
|
|
|
2213
2293
|
* @example
|
|
2214
2294
|
* This example registers a listener that responds to any changes to any Cell.
|
|
2215
2295
|
*
|
|
2216
|
-
* ```
|
|
2296
|
+
* ```js
|
|
2217
2297
|
* const store = createStore().setTables({
|
|
2218
2298
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2219
2299
|
* });
|
|
@@ -2239,7 +2319,7 @@ export interface Store {
|
|
|
2239
2319
|
* This example registers a listener that responds to any changes to a
|
|
2240
2320
|
* specific Cell, and which also mutates the Store itself.
|
|
2241
2321
|
*
|
|
2242
|
-
* ```
|
|
2322
|
+
* ```js
|
|
2243
2323
|
* const store = createStore().setTables({
|
|
2244
2324
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2245
2325
|
* });
|
|
@@ -2283,7 +2363,7 @@ export interface Store {
|
|
|
2283
2363
|
* valid values. After that list changes, the listener is called to apply the
|
|
2284
2364
|
* condition to the existing data.
|
|
2285
2365
|
*
|
|
2286
|
-
* ```
|
|
2366
|
+
* ```js
|
|
2287
2367
|
* const validColors = ['walnut', 'brown', 'black'];
|
|
2288
2368
|
* const store = createStore();
|
|
2289
2369
|
* const listenerId = store.addCellListener(
|
|
@@ -2328,7 +2408,7 @@ export interface Store {
|
|
|
2328
2408
|
* @example
|
|
2329
2409
|
* This example registers a listener and then removes it.
|
|
2330
2410
|
*
|
|
2331
|
-
* ```
|
|
2411
|
+
* ```js
|
|
2332
2412
|
* const store = createStore().setTables({
|
|
2333
2413
|
* pets: {fido: {species: 'dog', color: 'brown'}},
|
|
2334
2414
|
* });
|
|
@@ -2365,7 +2445,7 @@ export interface Store {
|
|
|
2365
2445
|
* @example
|
|
2366
2446
|
* This example gets the listener statistics of a small and simple Store.
|
|
2367
2447
|
*
|
|
2368
|
-
* ```
|
|
2448
|
+
* ```js
|
|
2369
2449
|
* const store = createStore();
|
|
2370
2450
|
* store.addTablesListener(() => console.log('Tables changed'));
|
|
2371
2451
|
* store.addRowIdsListener(() => console.log('Row Ids changed'));
|
|
@@ -2392,7 +2472,7 @@ export interface Store {
|
|
|
2392
2472
|
* @example
|
|
2393
2473
|
* This example creates a Store.
|
|
2394
2474
|
*
|
|
2395
|
-
* ```
|
|
2475
|
+
* ```js
|
|
2396
2476
|
* const store = createStore();
|
|
2397
2477
|
* console.log(store.getTables());
|
|
2398
2478
|
* // -> {}
|
|
@@ -2400,7 +2480,7 @@ export interface Store {
|
|
|
2400
2480
|
* @example
|
|
2401
2481
|
* This example creates a Store with some initial data:
|
|
2402
2482
|
*
|
|
2403
|
-
* ```
|
|
2483
|
+
* ```js
|
|
2404
2484
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
2405
2485
|
* console.log(store.getTables());
|
|
2406
2486
|
* // -> {pets: {fido: {species: 'dog'}}}
|
|
@@ -2408,7 +2488,7 @@ export interface Store {
|
|
|
2408
2488
|
* @example
|
|
2409
2489
|
* This example creates a Store with some initial data and a Schema:
|
|
2410
2490
|
*
|
|
2411
|
-
* ```
|
|
2491
|
+
* ```js
|
|
2412
2492
|
* const store = createStore()
|
|
2413
2493
|
* .setTables({pets: {fido: {species: 'dog'}}})
|
|
2414
2494
|
* .setSchema({
|
|
@@ -2420,5 +2500,7 @@ export interface Store {
|
|
|
2420
2500
|
* console.log(store.getTables());
|
|
2421
2501
|
* // -> {pets: {fido: {species: 'dog', sold: false}}}
|
|
2422
2502
|
* ```
|
|
2503
|
+
* @see The Basics guides
|
|
2504
|
+
* @category Creation
|
|
2423
2505
|
*/
|
|
2424
2506
|
export function createStore(): Store;
|