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

Access to the localstorage from native #22

Closed
baptistejamin opened this issue Jun 30, 2014 · 3 comments
Closed

Access to the localstorage from native #22

baptistejamin opened this issue Jun 30, 2014 · 3 comments

Comments

@baptistejamin
Copy link
Contributor

Hi Guys!

It could be really cool to access to cobalt.storage, but from the native part to get/store config vars, etc.

@ggendre
Copy link
Contributor

ggendre commented Jun 30, 2014

I think it is possible. At least from Android. There is a LocalStorage public class in Cobalt that you can use.

On iOS it's not available but you can easily add the "setItem", "getItem", "removetItem", and "clear" events in cobalt init, and forward the parameters to cobalt.storage.getItem, cobalt.storage.setItem and so on.

here is a quick untested example :

cobalt.init({
    events:{
        "setItem":function(data, callback){
            cobalt.storage.setItem(data.key, data.value, data.type)
        },
        "getItem":function(data, callback){
            if (callback){
                cobalt.sendCallback( callback, { value : cobalt.storage.getItem(data.key, data.type)} )
            }
        }
    } 
    //and so on...
});

@ggendre
Copy link
Contributor

ggendre commented Jun 30, 2014

anyway we keep this idea as an enhancement
thanks for the idea

@ggendre
Copy link
Contributor

ggendre commented Mar 21, 2019

duplicate of #118

@ggendre ggendre closed this as completed Mar 21, 2019
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

2 participants