-
-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: V3 🫴 #656
Merged
Merged
feat: V3 🫴 #656
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment was marked as resolved.
This comment was marked as resolved.
nvm - it runs on iOS! 🎉 now to Android... |
I try beta 2, the build don't work check logs : https://pastebin.com/VUjTDFzV I fixed that in node_modules files:
|
Yea this seems like a bug in RN Community CLI. The path is wrong when rebuilding. |
CI is green! 🎉🟢😍 react-native-mmkv V3 is ready 💪 I am a bit hesitant on merging this to main because it requires the new architecture... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
V3
react-native-mmkv V3 brings a ton of new features! 🥳
Bridgeless TurboModule
react-native-mmkv is now a bridgeless C++ TurboModule.
This means, there is no more Java or Objective-C code required for module initialization, everything is handled synchronously on the JS thread.
react-native-mmkv already was a JSI module before, so the performance improvements are only marginal.
But the codebase is now shared across iOS and Android, so the implementation is no longer duplicated! 🥳
New APIs:
trim()
andsize
V3 adds two new APIs to react-native-mmkv:
trim()
: Trim a MMKV storage unit. This can be called after deleting a bunch of keys (as deletions don't resize the storage), or when receiving a memory warning by the OS. You don't need to call this though.size
: Gets the current actual size of the storage unit, in bytes.Example:
New config option:
mode
A new option has been added to the
MMKV
constructor:mode
.mode
can be one of two values:Mode.SINGLE_PROCESS
: The MMKV instance is only used from a single process (this app).Mode.MULTI_PROCESS
: The MMKV instance may be used from multiple processes, such as app clips, share extensions or background services.Example:
Buffer improvements
The Buffer APIs have improved.
Uint8Array
,getBuffer(...)
andset(.., buffer)
now useArrayBuffer
as a type. If you want to write Uint8's, you can still usenew Uint8Array(arrayBuffer)
, butArrayBuffer
is the way to go in most cases.ArrayBuffer
is faster to use thanUint8Array
/TypedArray
set(key, buffer)
now performs one less copy, which could yield huge performance improvements when working with larger buffers.getBuffer(...)
now performs one less copy, which could yield huge performance improvements when working with larger buffers.MMKV Core on iOS
Since react-native-mmkv V3 is now a cross-platform C++ TurboModule (or xplat/"CxxTurboModule"), we are also now using MMKV-Core instead of MMKV-iOS for the iOS codebase.
For simple values (such as numbers or booleans) this now uses C++ directly, instead of going through Objective-C/NSObjects. This could potentially lead to another performance gain.
Note: react-native-mmkv V3 requires react-native 0.74 or higher, and requires the new architecture (TurboModules/CodeGen) to be enabled.
For the sake of simplicity, there will be no backwards compatibility for old architecture (bridge), or RN <0.73.