0.2.4 • Published 5 years ago

@wranggle/storage-chrome-adapter v0.2.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 years ago

ChromeAdapter

The ChromeAdapter lets WranggleStorage use the Google Chrome Storage API for its underlying persistent store in a browser extension.

Constructing WranggleStorage with ChromeAdapter

You can apply this adapter using the chrome or chromeSynchronized shortcuts when constructing your WranggleStorage instance.

chrome specifies the chrome.storage.local API, and chromeSynchronized specifies the chrome.storage.sync API.

Eg:

const store = new WranggleStorage({ chrome: true }); // or new WranggleStorage('chrome')

Installing From Individual Packages

For a web page, it is easiest to use the @wranggle/storage-web bundle.

Or you can add/install individual packages:

  1. Add the @wranggle/storage-core and @wranggle/storage-chrome-adapter packages to your project:

    # From the command line using yarn:
    yarn add @wranggle/storage-core @wranggle/storage-chrome-adapter
    
    # or with npm:
    npm install @wranggle/storage-core @wranggle/storage-chrome-adapter
  2. In your JavaScript, import or require the packages:

    import WranggleStorage from '@wranggle/storage-core'; 
    import ChromeAdapter from '@wranggle/storage-chrome-adapter'
    // or:
    const WranggleStorage = require('@wranggle/storage-core');
    const ChromeAdapter = require('@wranggle/storage-chrome-adapter')
  3. Instantiate your store:

    const store = new WranggleStorage({ chrome: true });

    Or do so without the construction shortcut:

    const store = new WranggleStorage({ persist: new ChromeAdapter({ location: 'local' }));