Open
Conversation
mrousavy
requested changes
Nov 24, 2023
Owner
mrousavy
left a comment
There was a problem hiding this comment.
Hey, thanks for your PR man!
Left some comments
src/MMKV.ts
Outdated
| * _Notice_: On iOS, this will automatically be set to MMKVMode.MultiProcess if you set an AppGroup in the plist configuration. | ||
| * More information on AppGroups [here](https://github.com/mrousavy/react-native-mmkv/tree/master#app-groups) | ||
| */ | ||
| mode?: MMKVMode; |
Owner
There was a problem hiding this comment.
Can you please use TypeScript unions instead of enums here?
So instead of mode?: MMKVMode it would be mode?: 'single-process' | 'multi-process'
README.md
Outdated
| * `id`: The MMKV instance's ID. If you want to use multiple instances, use different IDs. For example, you can separate the global app's storage and a logged-in user's storage. (required if `path` or `encryptionKey` fields are specified, otherwise defaults to: `'mmkv.default'`) | ||
| * `path`: The MMKV instance's root path. By default, MMKV stores file inside `$(Documents)/mmkv/`. You can customize MMKV's root directory on MMKV initialization (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#customize-location) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#customize-location)) | ||
| * `encryptionKey`: The MMKV instance's encryption/decryption key. By default, MMKV stores all key-values in plain text on file, relying on iOS's/Android's sandbox to make sure the file is encrypted. Should you worry about information leaking, you can choose to encrypt MMKV. (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#encryption) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#encryption)) | ||
| * `mode`: *Android Only*: The MMKV mode. It is set to SingleProcess by default. You can set its value to MultiProcess to support simultaneous read-write access between processus at the cost of performance. This is useful when you want to share data between your react-native app and native extensions such as widgets. _Notice_: On iOS, this will automatically be set to MMKVMode.MultiProcess if you set an AppGroup in the plist configuration (more information on AppGroups [here](https://github.com/mrousavy/react-native-mmkv/tree/master#app-groups)) |
Owner
There was a problem hiding this comment.
Is it possible to also use this prop for iOS? I hate having "android only" or "ios only" props... Maybe we can just reconfigure the instance on iOS when this prop is passed?
Author
There was a problem hiding this comment.
Author
There was a problem hiding this comment.
I could however add support for single-process mode with AppGroups but I'm not sure why would anyone want to do that.
Closed
This file contains hidden or 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
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.

This PR adds MultiProcess mode support on Android. iOS already supports this mode using AppGroups.
On android, widgets run in a different processus and this needs to be enabled to share data between native widgets and the main react-native app.