Skip to content
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

v0.9.0 - What can we add/change or enhance? #213

Open
7 of 10 tasks
ammarahm-ed opened this issue Feb 5, 2022 · 34 comments
Open
7 of 10 tasks

v0.9.0 - What can we add/change or enhance? #213

ammarahm-ed opened this issue Feb 5, 2022 · 34 comments

Comments

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Feb 5, 2022

I have some ideas on how we can make the library even better.

v0.7.0 (Released)

  • Migrate to typescript
  • Optionally persist default values in hooks
  • Add a way to mock the library with Jest
  • Add tests for mocked storage
  • Expo support

v0.9.0

  • Add e2e tests
  • Web support
  • Implement a non-blocking async API for writing large values to storage without blocking the JS thread
  • Implement async multiGet & multiSet functions for intensive read/write
  • Improve state updates. provide a state selector or do shallow compare internally

Anything else.. drop a comment below and we can discuss

@robkainz
Copy link

robkainz commented Feb 7, 2022

Is there currently a way to retrieve all key/value pairs like in AsyncStorage, which was used to migrate to MMKV? That may be helpful.

@ammarahm-ed
Copy link
Owner Author

@robkainz Just use storageInstance.indexer.

@ammarahm-ed ammarahm-ed pinned this issue Feb 13, 2022
@ahmedu007
Copy link

Mocks for Jest please 🙏

@ammarahm-ed
Copy link
Owner Author

@ahmedu007 in progress

@ammarahm-ed ammarahm-ed changed the title v0.7.0 - What can we add/change or enhance? v0.8.0 - What can we add/change or enhance? Apr 12, 2022
@ammarahm-ed
Copy link
Owner Author

@ahmedu007 jest mocks shipped in v0.7.0

@dancixx
Copy link

dancixx commented Apr 13, 2022

For first thanks for your work. ❤️❤️
Btw. I tried to use this package with the new expo-modules, expo sdk 44+ but I always get an error that mmkv package can not be found. I use rn bare workflow with some expo package. There is any futher steps to use them together?

@ammarahm-ed
Copy link
Owner Author

ammarahm-ed commented Apr 13, 2022

@dancixx Did you run expo prebuild? Also can you share the exact error that you are getting?

@dancixx
Copy link

dancixx commented Apr 13, 2022

@ammarahm-ed yes I run it, but got the same error, but I think the error is on my side, so I will drop the expo in the near future. Maybe I give it one more chance for it this weekend I write the result.

@haydenmlh
Copy link

Hi, I have a strange error when I try to store a map as a value in MMKV storage. After saving a map and reopening the app, the map is empty, but the strings I stored in other keys are there. Is this a known issue?

@ammarahm-ed
Copy link
Owner Author

Hi, I have a strange error when I try to store a map as a value in MMKV storage. After saving a map and reopening the app, the map is empty, but the strings I stored in other keys are there. Is this a known issue?

Convert map to simple object before saving in storage.

@haydenmlh
Copy link

Thank you, that works.

@exotexot
Copy link

Will there be support for react-native-windows?
As it is a c++ lib, maybe be an easy addition to this repo! :)

@humaidk2
Copy link

humaidk2 commented Jun 1, 2022

Hi,

Would be nice to have support for groupId when initializing mmkv. Recently got it to work with the help I got from @ammarahm-ed , but I still need to test encrypted store.

Also how would you support web? by replacing with local storage?

@ammarahm-ed
Copy link
Owner Author

ammarahm-ed commented Jun 1, 2022

@humaidk2 For web, we will use local-forage and only expose an async API. A sync wrapper around localStorage is possible but not very performant with no support for encryption. It's WIP.

groupId can be supported but only through adding a value to info.plist file which will be the simplest and best way. Doing it through JS won't be safe.

@humaidk2
Copy link

humaidk2 commented Jun 1, 2022

Wow I didn't know about local-forage,

I don't mean to ask too many questions here but what if the data can't be stored on web. Since web is really limited compared to mmkv. Technically, the developer could create a smaller web mmkv instance and migrate data through that.

info.plist sounds like a cool plan, considering the bundle id is already there, it would be easier to differentiate between build flavors too.

Also I'm guessing for e2e, you're looking to use detox? I do recommend it, it seems the build problems are gone and it's working well with latest react native.

@ammarahm-ed
Copy link
Owner Author

@humaidk2 local-forage is quite close to mmkv in architecture with support for multiple instances etc. The only difference is that mmkv is fully sync while local-forage is async storage. Hence the limitation of web to only use async methods while use localStorage for the sync API with a warning. There's already a branch were I am working on the implementation.

And yes, detox would be it.

@djintalkalan
Copy link

djintalkalan commented Jun 10, 2022

🙏🙏 Please add an equalityFn like useSelector of react-redux in useMMKVStorage hook.
const result: any = useSelector(selector: Function, equalityFn?: Function)
It helps to reduce unnecessary re-rendering of component when value is not changed.

@ammarahm-ed
Copy link
Owner Author

@djintalkalan will add this.

@pnthach95
Copy link
Contributor

Hi @ammarahm-ed, I published Flipper plugin for this library, you can add it to somewhere in your document website.

demo

@ammarahm-ed
Copy link
Owner Author

@pnthach95 That's great! I will update the docs once in release v0.8.0 this Sunday.

@ammarahm-ed ammarahm-ed changed the title v0.8.0 - What can we add/change or enhance? v0.9.0 - What can we add/change or enhance? Jul 31, 2022
@crypt0miester
Copy link

would love it if we can add ttl type of expiration to the keys.

@ammarahm-ed
Copy link
Owner Author

@crypt0miester What is the use-case for it

@crypt0miester
Copy link

@crypt0miester What is the use-case for it

caching would be a good use case.

@billouboq
Copy link

billouboq commented Aug 26, 2023

Implement a non-blocking async API for writing large values to storage without blocking the JS thread
Implement async multiGet & multiSet functions for intensive read/write

Those 2 things would be so dope !

Using react-native-mmkv-storage for react-redux and it can be very huge amount of data sometimes

Edit just saw we already have it, perfect 😄

@ammarahm-ed
Copy link
Owner Author

Implement a non-blocking async API for writing large values to storage without blocking the JS thread
Implement async multiGet & multiSet functions for intensive read/write

Those 2 things would be so dope !

Using react-native-mmkv-storage for react-redux and it can be very huge amount of data sometimes

Edit just saw we already have it, perfect 😄

You can try async get/set for items in bulk in the latest alpha, v0.10.0

@ammarahm-ed
Copy link
Owner Author

ammarahm-ed commented Aug 28, 2023

Implement a non-blocking async API for writing large values to storage without blocking the JS thread
Implement async multiGet & multiSet functions for intensive read/write

Those 2 things would be so dope !

Using react-native-mmkv-storage for react-redux and it can be very huge amount of data sometimes

Edit just saw we already have it, perfect 😄

You can try async get/set for items in bulk in the latest alpha, v0.10.0. Haven't added multiGet/multiSet polyfills yet but we have setMultipleItemsAsync/getMultipleItemsAsync which do most of the work off the js thread by default.

@billouboq
Copy link

Yeah saw about the setMultipleItemsAsync/getMultipleItemsAsync.

Thank you very much, this is a very good library 👍

@landabaso
Copy link

Thanks @ammarahm-ed for the great work on this package. I have a couple of questions:

  • Do the *Async functions leverage native threads? Are they non-blocking, or is this still being developed?
  • Is there a web implementation in v10 (alpha)? Couldn't find it. Might go with idb-keyval for similar Async functionality for Web if it's not available since both APIs look quite similar (using *Async).

Cheers.

@landabaso
Copy link

I've noticed that the Async methods currently serve as wrappers over regular methods.

getStringAsync(key: string): Promise<string | null | undefined> {

@ammarahm-ed , in the evolution of this package, is there a plan to integrate native async calls into these wrappers in future updates?

Also, I'd like to ask if this package could be used to store binary data compactly (without serializing to strings)?

@arasrezaei
Copy link

thanks for great library, please consider adding web support

@pnthach95
Copy link
Contributor

New Architecture is set by default in next version https://github.com/facebook/react-native/pull/43135/files

It's time to add New Architecture support

@chino
Copy link

chino commented Jul 25, 2024

@ammarahm-ed

@humaidk2 local-forage is quite close to mmkv in architecture with support for multiple instances etc. The only difference is that mmkv is fully sync while local-forage is async storage. Hence the limitation of web to only use async methods while use localStorage for the sync API with a warning. There's already a branch were I am working on the implementation.

And yes, detox would be it.

Did you ever continue on adding support for web?

@dppo
Copy link

dppo commented Aug 20, 2024

@ammarahm-ed

@humaidk2 local-forage is quite close to mmkv in architecture with support for multiple instances etc. The only difference is that mmkv is fully sync while local-forage is async storage. Hence the limitation of web to only use async methods while use localStorage for the sync API with a warning. There's already a branch were I am working on the implementation.
And yes, detox would be it.

Did you ever continue on adding support for web?

same question

@dev-whoan
Copy link

dev-whoan commented Sep 22, 2024

Is there any ways to get slices from array? Currently getArray returns all the values that matches with the given key, but sometimes I need to have part of them, not the whole values.

  • for example in chat application with large amounts of messages, we cannot load all that in once. it is not efficient. We can get it recent some messages, and read older when required.
  • not just messages posts, ...

Maybe we can set start index, and end index. getSlice(key, start_index, end_index?)

  • if we just call getArray(key), then returns all the values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests