GithubHelp home page GithubHelp logo

appdatapreferences-localstorage's Introduction

Appdata Preferences for Local Storage

Appdata Preferences for Local Storage seamessly syncs your local storage with Google Drive, you don't need to worry about persisting your user settings and application data anymore.

quickstart

Include appdatapreferences and configure it with an access token. Your access token need to be authorized for https://www.googleapis.com/auth/drive.appdata scope. You can go through one of the OAuth 2.0 flows to retrieve one or use Google+ Sign-In button.

Grab the dist/appdatapreferences.js and include it.

<script src="/path/to/appdatapreferences.js"></script>
<script>
    appdatapreferences.configure({ token: <access_token> });
    appdatapreferences.start();
</script>

Your storage will be initiated with the remote preferences on user's Drive. If this is the first time, your user is being synchronized with Google Drive, the library will initiate a new remote preferences file with his/her current local storage.

localStore['name'] = 'my name';

Continue to edit your localStorage and wait for your preferences to be synced. That's it.

reference

appdatapreferences.configure(opts)

Configures appdatapreferences, the options:

  • token: The access token authorized for appdata scope.
  • interval: The polling frequency to check if there are new remote changes are available.

appdatapreferences.sync(opt_callback)

Stops the currently running sync operation and syncs the local storage with remote preferences file. If there are remote changes available, merges the remote changes to local storage. If there has been a change to local storage since last sync, it uploads the local values to remote preferences.

appdatapreferences.start()

Stops the currently running sync operation and starts a periodic sync operation.

appdatapreferences.stop()

Stops the currently running sync operation and cancels the periodic sync.

contributors

You need to have npm and grunt-cli installed on your machine. Fork then init and update submodules to get a copy of Closure lib.

git submodule init && git submodule update

Install all dependencies:

npm install && bower install

Build to release a new distribution, the release output will be under /dist:

grunt build

appdatapreferences-localstorage's People

Contributors

rakyll avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

moritzt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.