@wranggle/storage-chrome-adapter
v0.2.4
Published
Use chrome.storage APIs as underlying store for WranggleStorage feature layers
Downloads
13
Maintainers
Readme
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:
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
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')
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' }));