React-native-web: AsyncStorage won't be in RN core anymore

Created on 27 Feb 2019  路  12Comments  路  Source: necolas/react-native-web

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

AsyncStorage module has been moved into a separate package https://github.com/react-native-community/react-native-async-storage

Describe a solution you'd like

Should we do something similar?

Describe alternatives you've considered

Since RNW is a monorepo, we could create react-native-async-storage-web (or react-native-web-async-storage.

Most helpful comment

Hey everyone :wave:

I'm maintainer of Async Storage on RN community Repo and I love the idea of having support for the web in the same repo. I'm up for doing adding this in upcoming days.

Regarding @piranna idea, my long-term plan for the library is to add a functionality similar to Adapter pattern used in Android community, where there's one public facing interface (getItem, setItem etc.), but underlying implementation is based on "adapter", which can change by developers/based on target platform. I believe this could help with hooking modules into react-native-web.

All 12 comments

Ideally, wouldn't a web implementation live in https://github.com/react-native-community/react-native-async-storage?

@SimenB if community is ok for it, I would say clearly YES.

Does someone want to open an issue in the community repo about moving the implementation there?

It would be just a copy&paste, but ideally, it would need to be an implementation wrapper of the low level platform dependent native implementation, added to the NativeModules object, so the high level logic is common to all platforms. This way it would be easier it gets merged and maintained upstream. Is that possible.

I like @piranna's idea. In fact I have just found this issue looking for a way to plug a "native" module for the web, after reading this issue: https://github.com/necolas/react-native-web/issues/470

If we had a standard way to hook our modules into react-native-web, it would be easier to implement (or mock) web versions of many react-native libraries.

Hey everyone :wave:

I'm maintainer of Async Storage on RN community Repo and I love the idea of having support for the web in the same repo. I'm up for doing adding this in upcoming days.

Regarding @piranna idea, my long-term plan for the library is to add a functionality similar to Adapter pattern used in Android community, where there's one public facing interface (getItem, setItem etc.), but underlying implementation is based on "adapter", which can change by developers/based on target platform. I believe this could help with hooking modules into react-native-web.

@Krizzu your idea looks nice, it would also allow to change what backend implementation to use :-)

Hey @piranna,

Thank you, and yes, that's exactly why I'd love to introduce this feature. I'll start to write roadmap, but in meantime, if someone would like to contribute, I'd be more than happy to help with Async Storage's web support.

@Krizzu if I am correct, you can probably just move the code from this repo (as it's supported) to yours?

As @MoOx says, just copying the existing code over for now would relieve us who try and run RN and RNWeb with the same codebase from having separate imports for async-storage

Before it's moved over to @react-native-community/async-storage we can do this with webpack alias, customize-cra for create-react-app

addWebpackAlias({
  '@react-native-community/async-storage': 'react-native-web/dist/exports/AsyncStorage/index.js'
}),

Please move this conversation to the repo where the API would be maintained.

https://github.com/react-native-community/react-native-async-storage/issues/52

Was this page helpful?
0 / 5 - 0 ratings