@iebh/vuex-tera-sync
v2.0.2
Published
A Vuex plugin for syncing state with Tera
Downloads
356
Readme
vuex-tera-sync
A Vuex plugin for syncing state with Tera.
Installation
npm install @iebh/vuex-tera-sync
Usage
Note: Make sure to remove any localforage/localstorage references in the store as this will create a bug where state gets carried over on new projects.
In your Vuex store configuration, initialize the plugin with createSyncPlugin(KEY)
where key is a unique identifier for the tool (e.g. wordFreq
or polyglot
, etc.):
import Vuex from 'vuex';
import { createSyncPlugin } from '@iebh/vuex-tera-sync';
const store = new Vuex.Store({
// ... your store configuration
// replace `wordFreq` with the unique identifying key
plugins: [createSyncPlugin('wordFreq')]
});
export default store;
In your main.js or app initialization:
import { setVueInstance, setTeraReady } from '@iebh/vuex-tera-sync';
import store from './store';
// ... your Vue app initialization
const app = new Vue({
store,
// ... your Vue app configuration
});
setVueInstance(app);
// After Tera is initialized
await terafy.init({
app,
Vue
});
setTeraReady();
app.$mount("#app");
API
createSyncPlugin(key)
: Creates the Vuex plugin for syncing with Tera. The key parameter specifies thekey
in the Tera state to be used for syncing.setVueInstance(instance)
: Sets the Vue instance for the sync plugin.setTeraReady()
: Signals that Tera is ready and initiates the first sync.
License
MIT