Skip to content

Synchronous get / set? #51

@adsee42

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

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