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

[feat] storePersistor option for createClient to pass through for createStore calls #542

Closed
509dave16 opened this issue May 16, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@509dave16
Copy link
Contributor

509dave16 commented May 16, 2022

Summary

@segment/sovran-react-native's export createStore has a persist option that allows for you to provide a Persistor. This is great for being able to leverage a faster storage library like MMKV.

However the createClient export of @segment/analytics-react-native does not pass through any config options to it's SovranStorage class which makes createStore function calls. Except for writeKey that is which maps to storeId in the SovranStorage class.

Proposed Solution

  1. createClient export's Config argument should include an option for storePersistor. Which will match the Persistor interface of @segment/sovran-react-native
  2. SovranStorage class needs either a second argument for storePersistor or it needs to have it own Config interface for the argument to support a storeId and storePersistor options.
  3. All createStore calls in SovranStorage class must pass persistor property in the persist object option.
@509dave16 509dave16 added the enhancement New feature or request label May 16, 2022
@509dave16 509dave16 changed the title [feat] storePersistor Pass Through Option for createStore calls [feat] storePersistor Pass through option for createStore calls May 16, 2022
@509dave16 509dave16 changed the title [feat] storePersistor Pass through option for createStore calls [feat] storePersistor option for createClient to pass through for createStore calls May 16, 2022
509dave16 added a commit to 509dave16/analytics-react-native that referenced this issue May 19, 2022
@alanjcharles alanjcharles reopened this May 31, 2022
@thianphat
Copy link

Hi @509dave16 , I was curious if you could provide an example of making this work with MMKV. I've tried adding the MMKV storage to storePersistor:

storePersistor: storage

Where storage is equal to new MMKV()

However, it's not working and of course, I am getting type errors where the methods don't align. How did you go about integrating this? Really appreciate it.

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

No branches or pull requests

3 participants