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

has asynchronous function? #234

Open
junhui75165 opened this issue May 23, 2017 · 4 comments
Open

has asynchronous function? #234

junhui75165 opened this issue May 23, 2017 · 4 comments

Comments

@junhui75165
Copy link

something like promise .then

@marcuswestin
Copy link
Owner

Can you write out a piece of example code that shows what you'd like to be able to do please?

@ghost
Copy link

ghost commented Oct 3, 2017

AFAIK, most storage mechanisms are synchronous so I'm not sure that exposing an async method would be safe. However, the following is probably what was intended:

import * as store from "store"

store.set("some_key", "some_keyed_value");

store.get("some_key")
    .then(value => { 
        console.log(value); 
        /* Should print 'some_keyed_value' to console */
    });

@genu
Copy link

genu commented Aug 26, 2018

This doesn't really make sense. Why would a read from localstorage by asynchronous?

@ghost
Copy link

ghost commented Aug 28, 2018

@genu Agreed, but there are async storage APIs out there which store.js could handle if it had an async capability. Although deprecated, WebSQL is an example of an async storage API, there may be others these days, but it's been a while since I looked.

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

No branches or pull requests

3 participants