Releases: tinyplex/tinybase
v3.2.0
This release lets you add a listener to the start of a transaction, and detect that a set of changes are about to be made to a Store.
To use this, call the addStartTransactionListener method on your Store. The listener you add can itself mutate the data in the Store.
From this release onwards, listeners added with the existing addWillFinishTransactionListener method are also able to mutate data. Transactions added with the existing addDidFinishTransactionListener method cannot mutate data.
const store = createStore();
const startListenerId = store.addStartTransactionListener(() => {
console.log('Start transaction');
console.log(store.getTables());
// Can mutate data
});
const willFinishListenerId = store.addWillFinishTransactionListener(() => {
console.log('Will finish transaction');
console.log(store.getTables());
// Can mutate data
});
const didFinishListenerId = store.addDidFinishTransactionListener(() => {
console.log('Did finish transaction');
console.log(store.getTables());
// Cannot mutate data
});
store.setTable('pets', {fido: {species: 'dog'}});
// -> 'Start transaction'
// -> {}
// -> 'Will finish transaction'
// -> {pets: {fido: {species: 'dog'}}}
// -> 'Did finish transaction'
// -> {pets: {fido: {species: 'dog'}}}
store
.delListener(startListenerId)
.delListener(willFinishListenerId)
.delListener(didFinishListenerId);This release also fixes a bug where using the explicit startTransaction method inside another listener could create infinite recursion.
v3.1.6
This adds types entry points to TinyBase's package.json so that the library can be used with TypeScript in the Vite bundler, for example.
If there are any import issues relating to this change, please file an issue.
v3.1.5
Upgrades all dependencies and fixes Puppeteer headless log spew
v3.1.4
This minor release fixes an issue where a Schema containing default Values can fail when using a persister initialized with no initial Values. Pretty niche but worth fixing!
v3.1.3
This is a minor release that addresses some documentation typos and upgrades the developer dependencies.
v3.1.2
This release optimizes the hot transformMap function, bringing minor speed and size improvements. It also update developer dependencies and fixes some docs typos.
v3.1.1
This new release adds a powerful schema-based type system to TinyBase.
If you define the shape and structure of your data with a TablesSchema or ValuesSchema, you can benefit from an enhanced developer experience when operating on it. For example:
// Import the 'with-schemas' definition:
import {createStore} from 'tinybase/with-schemas';
// Set a schema for a new Store:
const store = createStore().setValuesSchema({
employees: {type: 'number'},
open: {type: 'boolean', default: false},
});
// Benefit from inline TypeScript errors.
store.setValues({employees: 3}); // OK
store.setValues({employees: true}); // TypeScript error
store.setValues({employees: 3, website: 'pets.com'}); // TypeScript errorThe schema-based typing is used comprehensively throughout every module - from the core Store interface all the way through to the ui-react module. See the new Schema-Based Typing guide for instructions on how to use it.
This now means that there are three progressive ways to use TypeScript with TinyBase:
- Basic Type Support (since v1.0)
- Schema-based Typing (since v3.1)
- ORM-like type definitions (since v2.2)
These are each described in the new TinyBase and TypeScript guide.
Also in v3.1, the ORM-like type definition generation in the tools module has been extended to emit ui-react module definitions.
Finally, v3.1.1 adds a reuseRowIds parameter to the addRow method and the useAddRowCallback hook. It defaults to true, for backwards compatibility, but if set to false, new Row Ids will not be reused unless the whole Table is deleted.
v3.0.6
Fixes a minor type declaration issue, some documentation issues, and updates dev-time dependencies.
v3.0.5
This release moves type definitions into a common ./lib/types folder that is shared by all of the flavors and targets of the TinyBase build & transpilation.
There should be no change to functionality or documentation. However, since duplicated .d.ts files have now been removed, the installed package is now 75% smaller.
v3.0.4
This improves import and type definitions for React Native in particular, but also for other flavors and targets. It addresses the frustrations of #59 and #28.
There is also a new Importing TinyBase guide to explain the options.
The main changes are in b182895 - please report any import problems this might have inadvertently introduced!