33This is a reverse chronological list of the major TinyBase releases, with
44highlighted features.
55
6+ ## v3.3
7+
8+ This release allows you to track the Cell Ids used across a whole Table,
9+ regardless of which Row they are in.
10+
11+ In a Table (particularly in a Store without a TablesSchema), different Rows can
12+ use different Cells. Consider this Store, where each pet has a different set of
13+ Cell Ids:
14+
15+ ``` js
16+ const store = createStore ();
17+
18+ store .setTable (' pets' , {
19+ fido: {species: ' dog' },
20+ felix: {species: ' cat' , friendly: true },
21+ cujo: {legs: 4 },
22+ });
23+ ```
24+
25+ Prior to v3.3, you could only get the Cell Ids used in each Row at a time (with
26+ the getCellIds method). But you can now use the getTableCellIds method to get
27+ the union of all the Cell Ids used across the Table:
28+
29+ ``` js
30+ console .log (store .getCellIds (' pets' , ' fido' )); // previously available
31+ // -> ['species']
32+
33+ console .log (store .getTableCellIds (' pets' )); // new in v3.3
34+ // -> ['species', 'friendly', 'legs']
35+ ```
36+
37+ You can register a listener to track the Cell Ids used across a Table with the
38+ new addTableCellIdsListener method. Use cases for this might include knowing
39+ which headers to render when displaying a sparse Table in a user interface, or
40+ synchronizing data with relational or column-oriented database system.
41+
42+ There is also a corresponding useTableCellIds hook in the optional ui-react
43+ module for accessing these Ids reactively, and a useTableCellIdsListener hook
44+ for more advanced purposes.
45+
46+ Note that the bookkeeping behind these new accessors and listeners is efficient
47+ and should not be slowed by the number of Rows in the Table.
48+
49+ This release also passes a getIdChanges function to every Id-related listener
50+ that, when called, returns information about the Id changes, both additions and
51+ removals, during a transaction. See the TableIdsListener type, for example.
52+
53+ ``` js
54+ let listenerId = store .addRowIdsListener (
55+ ' pets' ,
56+ (store , tableId , getIdChanges ) => {
57+ console .log (getIdChanges ());
58+ },
59+ );
60+
61+ store .setRow (' pets' , ' lowly' , {species: ' worm' });
62+ // -> {lowly: 1}
63+
64+ store .delRow (' pets' , ' felix' );
65+ // -> {felix: -1}
66+
67+ store .delListener (listenerId).delTables ();
68+ ```
69+
670## v3.2
771
872This release lets you add a listener to the start of a transaction, and detect
@@ -17,8 +81,6 @@ Transactions added with the existing addDidFinishTransactionListener method
1781_ cannot_ mutate data.
1882
1983``` js
20- const store = createStore ();
21-
2284const startListenerId = store .addStartTransactionListener (() => {
2385 console .log (' Start transaction' );
2486 console .log (store .getTables ());
@@ -112,7 +174,7 @@ store.setValues({employees: 3, open: true});
112174console .log (store .getValues ());
113175// -> {employees: 3, open: true}
114176
115- const listenerId = store .addValueListener (
177+ listenerId = store .addValueListener (
116178 null ,
117179 (store , valueId , newValue , oldValue ) => {
118180 console .log (` Value '${ valueId} ' changed from ${ oldValue} to ${ newValue} ` );
0 commit comments