v0.6.1
- Trigger
useMMKVStoragechange whenremoveItemis called - move
getAllMMKVInstanceIDsandgetCurrentMMKVInstanceIDsto module level hasKeyfunctions in indexer are now synchronous- Allow changing when
keyand/orstorageinuseMMKVStoragehook at runtime - Add
clearMemoryCachefunction - Add
getKeyfunction to get encryption key of current MMKV instance - Prevent a possible crash when sending incorrect parameters to
createfunction. - Do not recompile jsi.cpp from source on Android
- Now you can set a
defaultValueforuseMMKVStoragehook. - Fix a
nullexception during migration if value for a key was null - Fix numerous build issues on Android such as #155
- Fix
setValuenot stable inuseMMKVStoragehook #157 - Fix value type of
useMMKVStoragehook could not be changed after it was deleted. - Refactor and simplify some parts of the library
- Update MMKV to
1.2.10
What's new
Transactions
Listen to a value's lifecycle and mutate it on the go. Transactions lets you register lifecycle functions with your storage instance such as onwrite, beforewrite, onread, ondelete. This allows for a better and more managed control over the storage and also let's you build custom indexes with a few lines of code. Refer to #104 issue more detail on this feature.
storage.transactions.register("object","onwrite",(key,value) => {
//do something
})Remember that these are not events but functions. If you register the same type of function twice, the later will take precedence.
useIndex
A hook that will take an array of keys and returns an array of values for those keys. This is supposed to work in combination with Transactions. When you have build your custom index, you will need an easy and quick way to load values for your index. useIndex hook actively listens to all read/write changes and updates the values accordingly.
const [posts, update,remove] = useIndex(postsIndex,"object",storage);