splitio / react-client

React JS SDK client for Split Software
https://split.io
Other
27 stars 9 forks source link

LocalStorage in a React-Native App #44

Closed Freire71 closed 3 years ago

Freire71 commented 3 years ago

Hi. I'm testing Split.io services. It works really well, but I'm in doubt about storage. When we initialize configs we follow the Browser interface. What happens when we select storage type: 'LocalStorage' in a React-Native environment? Should it be able to pass the AsyncStorage module to deal with it?

image

In another service named Apptimize it is possible in the following way: image

Freire71 commented 3 years ago

I intend to use Split.io in a critical part of my software. I'm searching for React-Native Async-Storage references and I've not found any. In this article: https://www.split.io/blog/controlled-rollout-react-native/ you guys tell about feature flag caching in Android and iOS how is this accomplished? Do I need to install both Android and iOS native SDKs to accomplish it? Is it necessary to create a bridge between those 2 SDKs and leave the ReactJS SDK to accomplish this result? No native code is involved in the ReactJS SDK and I'm a bit confused about the content described in the article.

Freire71 commented 3 years ago

The only that I've found is when local storage is not available the SDK will fall back into memory storage image

NicoZelaya commented 3 years ago

Hi @Freire71 !

We don't support AsyncStorage as a drop in replacement, given the API is different from LocalStorage (one is synchronous the other one asynchronous). It's in our backlog waiting to be prioritized, either to offer this module (in reality you'll be able to plug it in) as well as a React Native specific SDK for Split, so I would like to track a feature request in your name to help with prioritization. If you can tell me which company you work for I think I have enough data.

In regards with using it on a critical path or not, can you tell us what you expect to accomplish with Async-Storage that you can't today and it's needed for your use case? I'll try to advise but you can always reach out through support@split.io if you think we need a quick zoom to brainstorm through the options/potential caveats.

As for the post, my apologies if it was confusing, I'll speak with the author and we'll make corrections if needed, thank you very much for flagging!

Best, Nico.

Freire71 commented 3 years ago

Hi @NicoZelaya. Thank you for replying so fast!! I'm working for Sanar, it is a Health company located in Brazil. We are one of the biggest players in the Medical Residency Market. The critical part that I've told is is to use feature flags to control the selling of a digital course using Apple's In-App-Purchase. Is there any drawback of using your solution, since will not be possible to use stored values in the case of losing connection to Split's servers? Are there any docs telling how to deal with async calls to the react SDK? How can I ensure that a split is loaded? When these variables are loaded. Is it a lazy load process? I would love to know how these internals works to ensure that no undesirable side effects will occur. For example, a course that should not be available to users to buy and it is.

computerjazz commented 3 years ago

+1 for this feature!

I'm also working on a React Native app in the health care space and we're evaluating feature flag options, and offline caching is one of our criteria. What a coincidence that this issue was opened as I'm comparing services!

As far as use case goes, if we can't cache flags offline we can't guarantee a consistent user experience. What if we turn on a feature for all users, then the user goes offline and relaunches? That new feature would seem to disappear, wouldn't it?

talianassi921 commented 3 years ago

Hi @Freire71 @computerjazz We updated the blog post and removed the caching section as it's not related to React, just Android and iOS. Like Nico said, We don't support AsyncStorage as a drop-in replacement, given the API is different from LocalStorage. A limitation we do have is that if you turn on a feature in react native and the user goes offline and relaunches, the user would get the default treatment.