ignite icon indicating copy to clipboard operation
ignite copied to clipboard

[Feature Request]: Migrate AsyncStorage -> MMKV

Open kieran-osgood opened this issue 2 years ago • 4 comments

Feature Request

I get it may not be wanted due to the fact most people know AsyncStorage, but do we think it would be a worthwhile upgrade to migrate from AsyncStorage to MMKV.

Pros

  • Significantly faster
  • MMKV has encryption support for secure local storage
  • Synchronous storage, so simpler application code

Cons

  • Slightly higher learning curve for people adopting ignite (but still easier to use due to synchronous storage)
  • Due to the fact it's built on JSI the the Chrome Debugger will no longer work and flipper is the alternative

Support

There appears to be an integration for persisting mobx store already too, though I haven't tested this yet https://github.com/mrousavy/react-native-mmkv/blob/master/docs/WRAPPER_MOBX.md

Realised a major caveat to it would be that expo is not able to autolink JSI yet, but there appears to be a plugin that can be configured for expo managed projects https://github.com/mrousavy/react-native-mmkv/issues/157 - so again something that would require some investigation if this sounds good.

I wanted to confirm if this is something that is agreed would be desirable, and I'm happy to work on a PR if so!

kieran-osgood avatar Oct 21 '21 07:10 kieran-osgood

Looks really good. The Expo integration would be the primary concern at this point. If we could get it to work well with Expo, then I’d be interested in a PR!

jamonholmgren avatar Oct 21 '21 14:10 jamonholmgren

On second thought, breaking the Chrome debugger might be a no-go. How many Ignite devs use the Chrome debugger?

jamonholmgren avatar Oct 22 '21 18:10 jamonholmgren

Hi, In react-native-mmkv installation, it says for Android:

Since react-native-reanimated also uses JSI, there will be conflicts if you install both libraries at the same time. That's why the installation steps are different:

Would be any problem with using ignite x react-native-mmkv x reanimated? And I see reactotron also uses AsyncStorage. We need to migrate it too. P.S. It's a great opportunity to use flipper, imo.

turker0 avatar Nov 23 '21 11:11 turker0

How many Ignite devs use the Chrome debugger?

Legions

I totally understand the point of @kieran-osgood and @oguzturker8 but by experience I have a feeling there are more

  • "React Devs who want to ship native app" <-------- these guys are using web tools Vs.
  • "Native Developers who use React"

flexbox avatar Dec 13 '21 20:12 flexbox

Recipe over at the Ignite Cookbook! https://ignitecookbook.com/docs/recipes/MigratingToMMKV

frankcalise avatar Oct 28 '22 14:10 frankcalise

Recipe over at the Ignite Cookbook! https://infinitered.github.io/ignite-cookbook/docs/MigratingToMMKV

Hey, the link is broken, can you update it please?

caiorrs avatar Jun 16 '23 18:06 caiorrs

@caiorrs updated! https://ignitecookbook.com/docs/recipes/MigratingToMMKV

frankcalise avatar Jun 16 '23 20:06 frankcalise

Thanks, @frankcalise, for the tutorial! I've applied your tips. Now, I'm looking to integrate MMKV with Reactotron instead of AsyncStorage here. Any advice on making this switch?

bi3ri avatar Feb 12 '24 12:02 bi3ri

@bi3ri hey yeah we should update that recipe (would welcome a PR if you want to help confirm and verify the steps!) to include the Reactotron plugin setup documented here: https://docs.infinite.red/reactotron/plugins/react-native-mmkv/

frankcalise avatar Feb 12 '24 13:02 frankcalise