这是indexloc提供的服务,不要输入任何密码
Skip to content

Support for asynchronous Storage (React Native) #19

@BenJeau

Description

@BenJeau

Using this package does not work with React Native since their Storage API (aka the AsyncStorage API, here's a link to their docs) is asynchronous and this package does not seem to support an asynchronous Storage API. This issue is to simply open the conversation this subject.

The following is what I used to set the storage:

const {persistAtom} = recoilPersist({
  storage: AsyncStorage,
});

The error message:

There's an error here since toParse is a Promise.
image

Looking at the code, you could check if getItem() or/and setItem() is a promise to know if its async or not, then transform the functions to be async. This is potentially a naïve idea, but I'm not sure how it could be implemented otherwise, maybe you have a better idea on its implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions