This differential extends MMKV API with integer getter and setter, function to retrieve all keys in the db and function to remove subset of keys from the db.
Details
iOS:
- Below the comm::CommMMKV::initialize() line add lines that set several different integers under different keys.
- In NotificationService.mm at the beginning add lines that:
- Get all keys.
- Tries to get value for each key.
- Then call remove with one-element array with one key.
- Get all keys again and log them.
- Send notification and check that all integers are logged and the set of keys logged doesn't contain the one passed to removeKeys.
Android:
- Below the CommMMKV.initialize() line add lines that set several different integers under different keys.
- In CommNotificationsHandler.java at the beginning add lines that:
- Get all keys.
- Tries to get value for each key.
- Then call remove with one-element array with one key.
- Get all keys again and log them.
- Send notification and check that all integers are logged and the set of keys logged doesn't contain the one passed to removeKeys.
Diff Detail
- Repository
- rCOMM Comm
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
native/cpp/CommonCpp/Tools/CommMMKV.h | ||
---|---|---|
17 ↗ | (On Diff #37009) | MMKV API can't return null when we try to get integer that doesn't exist. It allows us to set default value that is returned instead in case the integer isn't present. So my idea here is that the developer should pass as noValue the value that they believe should never be set under certain key. For example if we use this for unreadCount we could pass -1 since unread count is never negative. Our implementation passes this as default value and if MMKV returns default value then our implementation returns nullish integer (null in Java and std::nullopt in C++ and Objective-C). |
native/android/app/src/cpp/CommMMKV.cpp | ||
---|---|---|
83 ↗ | (On Diff #37020) | What is the result of make_jstring? Are we dereferencing a pointer? Should we free the memory at the end? |
85 ↗ | (On Diff #37020) | Why can the setString method accept std::string but removeKeys need to transform the parameters using make_jstring? |
native/cpp/CommonCpp/Tools/CommMMKV.h | ||
17 ↗ | (On Diff #37009) | Can we explain it in a code comment? |
native/android/app/src/cpp/CommMMKV.cpp | ||
---|---|---|
83 ↗ | (On Diff #37020) |
Calling make_jstring returns local_ref.. See here.
The following fbjni doc explains that underlying objects are destructed when reference is destructed. Additionally this docs states explicitly that local_ref follows reference counting destruction paradigm. |
85 ↗ | (On Diff #37020) |
This fbjni doc states explicitely that C++ methods calling Java can work with both std::string and JString.
There is no similar conversion from std::vector<T> to JArrayClass<T> unfortunately. Working with arrays is explained here.
The setElement method of JArrayClass<T> expects that we are setting an object that is plain JNI reference. |
native/cpp/CommonCpp/Tools/CommMMKV.h | ||
---|---|---|
25 ↗ | (On Diff #37925) | Explanation of noValue argument. |