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

Provide an option to set custom storage #436

Closed
artyorsh opened this issue Apr 12, 2024 · 3 comments · Fixed by #539
Closed

Provide an option to set custom storage #436

artyorsh opened this issue Apr 12, 2024 · 3 comments · Fixed by #539
Labels
enhancement New feature or request feature Label for feature requests package: sdk/react-native Issues that affect the react native SDK. Stale

Comments

@artyorsh
Copy link

Is your feature request related to a problem? Please describe.

In react-native, the SDK uses @react-native-async-storage/async-storage package without an option to specify a custom destination for SDK keys. This mixes app-related keys with SDK keys, which is especially painful when migrating to a different library (say, MMKV). This also blocks apps from removing async-storage dependency.

Describe the solution you'd like

import { AutoEnvAttributes, ReactNativeLDClient, LDStorage } from '@launchdarkly/react-native-client-sdk';

const customStorage: LDStorage = {
  getItem: (k) => { mmkv.get(k) },
  setItem: (k, v) => { mmkv.set(k, v) },
};

const client = new ReactNativeLDClient(
  'mobile-key',
  AutoEnvAttributes.Enabled,
  { storage: customStorage },
);

Describe alternatives you've considered

Providing a documentation on what keys are stored by SDK would also work, giving an option to filter async-storage.

@artyorsh artyorsh added feature Label for feature requests package: shared/common Label for issues affecting the shared/common package. labels Apr 12, 2024
@yusinto yusinto added the enhancement New feature or request label Apr 15, 2024
@yusinto
Copy link
Contributor

yusinto commented Apr 15, 2024

We will investigate this. Internally logged 240413.

@angelo-hub
Copy link

+1 on this, we try to use mmkv for everything

@kinyoklion kinyoklion added package: sdk/react-native Issues that affect the react native SDK. and removed package: shared/common Label for issues affecting the shared/common package. labels Apr 23, 2024
Copy link
Contributor

This issue is stale because it has been open for 90 days without activity. Remove the stale label or comment, or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jul 23, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2024
kinyoklion added a commit that referenced this issue Aug 27, 2024
This PR fixes #436 by
implementing a custom storage option to the React Native package.

The main motivation is to get rid of the obsolete async storage package,
but we also found that having multiple clients as [recommended by the
official
docs](https://docs.launchdarkly.com/sdk/features/multiple-environments#react-native)
when migrating away from `secondaryMobileKeys` in v9 caused them to
overwrite each other's storage and therefore effectively disabling the
storage/cache altogether.

---------

Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature Label for feature requests package: sdk/react-native Issues that affect the react native SDK. Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants