Skip to content

Commit 104af87

Browse files
committed
[mmkv] createMMKV
1 parent 3252e0f commit 104af87

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

releases.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ await persister.destroy();
2222
<p>That&#x27;s it! If you&#x27;ve used other TinyBase persisters, this API should be easy and familiar to use.</p><p>One caveat: observability in OPFS is not yet standardized in browsers. This means that the auto-load functionality of the persister may not work as expected, although a best effort is made using the experimental FileSystemObserverAPI, so please let us know how that works!</p><hr><h1 id="v6-6">v6.6</h1><p>This release improves the Inspector tool, making it easier to debug, inspect, and mutate your TinyBase stores.</p><p><img src="https://tinybase.org/inspector.webp" alt="Inspector" title="Inspector"></p><p>As well as a modernized UI, new in this release is the ability to create, duplicate, or delete tables, rows, values and cells directly within the Inspector. Press the &#x27;pencil&#x27; icon to start editing items, and then hover over the new icons to see how to manipulate the data.</p><p>See the <a href="https://tinybase.org/guides/inspecting-data/">Inspecting Data</a> guide for more information about how to use the Inspector in your application during development.</p><h1 id="v6-5">v6.5</h1><p>This release includes the new <a href="https://tinybase.org/api/persister-react-native-mmkv/"><code>persister-react-native-mmkv</code></a> module, which allows you to persist data in a React Native MMKV store via the <a href="https://github.com/mrousavy/react-native-mmkv">react-native-mmkv</a> library.</p><p>Usage should be as simple as this:</p>
2323

2424
```js yolo
25-
import {MMKV} from 'react-native-mmkv';
25+
import {createMMKV} from 'react-native-mmkv';
2626
import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
2727

28-
const storage = new MMKV();
28+
const storage = createMMKV();
2929
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
3030
const persister = createReactNativeMmkvPersister(store, storage);
3131

@@ -675,4 +675,4 @@ store.finishTransaction();
675675
// -> 'Fido changed'
676676
```
677677

678-
<p>In addition, see the <a href="https://tinybase.org/api/store/interfaces/store/store/methods/listener/addwillfinishtransactionlistener/"><code>addWillFinishTransactionListener</code></a> method and the <a href="https://tinybase.org/api/store/interfaces/store/store/methods/listener/adddidfinishtransactionlistener/"><code>addDidFinishTransactionListener</code></a> method for details around listening to transactions completing.</p><p>Together, this release allows stores to couple their transaction life-cycles together, which we need for the query engine.</p><p>Note: this API was updated to be more comprehensive in v4.0.</p><hr><h1 id="v1-2">v1.2</h1><p>This adds a way to revert transactions if they have not met certain conditions.</p><p>When using the <a href="https://tinybase.org/api/the-essentials/setting-data/transaction/"><code>transaction</code></a> method, you can provide an optional <code>doRollback</code> callback which should return true if you want to revert the whole transaction at its conclusion.</p><p>The callback is provided with two objects, <code>changedCells</code> and <code>invalidCells</code>, which list all the net changes and invalid attempts at changes that were made during the transaction. You will most likely use the contents of those objects to decide whether the transaction should be rolled back.</p><p>Note: this API was updated to be more comprehensive in v4.0.</p><hr><h1 id="v1-1">v1.1</h1><p>This release allows you to listen to invalid data being added to a <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a>, allowing you to gracefully handle errors, rather than them failing silently.</p><p>There is a new listener type <a href="https://tinybase.org/api/store/type-aliases/listener/invalidcelllistener/"><code>InvalidCellListener</code></a> and a <a href="https://tinybase.org/api/store/interfaces/store/store/methods/listener/addinvalidcelllistener/"><code>addInvalidCellListener</code></a> method in the <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> interface.</p><p>These allow you to keep track of failed attempts to update the <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> with invalid <a href="https://tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> data. These listeners can also be mutators, allowing you to address any failed writes programmatically.</p><p>For more information, please see the <a href="https://tinybase.org/api/store/interfaces/store/store/methods/listener/addinvalidcelllistener/"><code>addInvalidCellListener</code></a> method documentation. In particular, this explains how this listener behaves for a <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> with a <a href="https://tinybase.org/api/store/type-aliases/schema/tablesschema/"><code>TablesSchema</code></a>.</p>
678+
<p>In addition, see the <a href="https://tinybase.org/api/store/interfaces/store/store/methods/listener/addwillfinishtransactionlistener/"><code>addWillFinishTransactionListener</code></a> method and the <a href="https://tinybase.org/api/store/interfaces/store/store/methods/listener/adddidfinishtransactionlistener/"><code>addDidFinishTransactionListener</code></a> method for details around listening to transactions completing.</p><p>Together, this release allows stores to couple their transaction life-cycles together, which we need for the query engine.</p><p>Note: this API was updated to be more comprehensive in v4.0.</p><hr><h1 id="v1-2">v1.2</h1><p>This adds a way to revert transactions if they have not met certain conditions.</p><p>When using the <a href="https://tinybase.org/api/the-essentials/setting-data/transaction/"><code>transaction</code></a> method, you can provide an optional <code>doRollback</code> callback which should return true if you want to revert the whole transaction at its conclusion.</p><p>The callback is provided with two objects, <code>changedCells</code> and <code>invalidCells</code>, which list all the net changes and invalid attempts at changes that were made during the transaction. You will most likely use the contents of those objects to decide whether the transaction should be rolled back.</p><p>Note: this API was updated to be more comprehensive in v4.0.</p><hr><h1 id="v1-1">v1.1</h1><p>This release allows you to listen to invalid data being added to a <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a>, allowing you to gracefully handle errors, rather than them failing silently.</p><p>There is a new listener type <a href="https://tinybase.org/api/store/type-aliases/listener/invalidcelllistener/"><code>InvalidCellListener</code></a> and a <a href="https://tinybase.org/api/store/interfaces/store/store/methods/listener/addinvalidcelllistener/"><code>addInvalidCellListener</code></a> method in the <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> interface.</p><p>These allow you to keep track of failed attempts to update the <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> with invalid <a href="https://tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> data. These listeners can also be mutators, allowing you to address any failed writes programmatically.</p><p>For more information, please see the <a href="https://tinybase.org/api/store/interfaces/store/store/methods/listener/addinvalidcelllistener/"><code>addInvalidCellListener</code></a> method documentation. In particular, this explains how this listener behaves for a <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> with a <a href="https://tinybase.org/api/store/type-aliases/schema/tablesschema/"><code>TablesSchema</code></a>.</p>

site/guides/15_releases.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ you to persist data in a React Native MMKV store via the
6464
Usage should be as simple as this:
6565

6666
```js yolo
67-
import {MMKV} from 'react-native-mmkv';
67+
import {createMMKV} from 'react-native-mmkv';
6868
import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
6969

70-
const storage = new MMKV();
70+
const storage = createMMKV();
7171
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
7272
const persister = createReactNativeMmkvPersister(store, storage);
7373

src/@types/persisters/persister-react-native-mmkv/docs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
* then gets the unique key of the storage location back out again.
3434
*
3535
* ```js yolo
36-
* import {MMKV} from 'react-native-mmkv';
36+
* import {createMMKV} from 'react-native-mmkv';
3737
* import {createStore} from 'tinybase';
3838
* import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
3939
*
40-
* const storage = new MMKV();
40+
* const storage = createMMKV();
4141
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
4242
* const persister = createReactNativeMmkvPersister(
4343
* store,
@@ -81,11 +81,11 @@
8181
* reloads it back into the Store.
8282
*
8383
* ```js yolo
84-
* import {MMKV} from 'react-native-mmkv';
84+
* import {createMMKV} from 'react-native-mmkv';
8585
* import {createStore} from 'tinybase';
8686
* import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
8787
*
88-
* const storage = new MMKV();
88+
* const storage = createMMKV();
8989
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
9090
* const persister = createReactNativeMmkvPersister(
9191
* store,

0 commit comments

Comments
 (0)