Skip to content

Synchronous get / set? #51

Description

@adsee42

Very helpful package! Thank you.

I'm using ImmortalDB with React to save some page state to local.
I would like to init a component's state by loading locally stored state, like:

const MyComponent = () => {
  const [state, setState] = useState(() => {
    return ImmortalDB.get('key')
  })
}

But ImmortalDB.get returns a Promise, so the above line would be return await ImmortalDB.get('key').
And React's useState does not support async functions,
so a synchronous get would be very helpful

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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