All Projects → gabrielmbmb → Vuex Multi Tab State

gabrielmbmb / Vuex Multi Tab State

Licence: mit
💾🔗🖥️ Share, synchronize and persist state between multiple tabs with this plugin for Vuex. TypeScript types included.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Vuex Multi Tab State

Vue Acl
Access Control List plugin for VueJS 2.0
Stars: ✭ 376 (+388.31%)
Mutual labels:  plugin, vuex
Hyper Tabs Enhanced
Enhanced Tabs Plugin for Hyper
Stars: ✭ 173 (+124.68%)
Mutual labels:  plugin, tabs
Duix
A State Manager focused on KISS and Pareto's Principle
Stars: ✭ 48 (-37.66%)
Mutual labels:  vuex, state
Vuex Easy Firestore
Easy coupling of firestore and a vuex module. 2-way sync with 0 boilerplate!
Stars: ✭ 224 (+190.91%)
Mutual labels:  sync, vuex
Vuex Persistedstate
💾 Persist and rehydrate your Vuex state between page reloads.
Stars: ✭ 5,561 (+7122.08%)
Mutual labels:  plugin, vuex
Reo
🍯 regularjs and stateman based spa framework, inspired by redux, vuex and choo
Stars: ✭ 14 (-81.82%)
Mutual labels:  vuex, state
Docsify Tabs
A docsify.js plugin for rendering tabbed content from markdown
Stars: ✭ 65 (-15.58%)
Mutual labels:  plugin, tabs
Wxappstore
微信小程序全局状态管理,并提供Vuex的开发体验
Stars: ✭ 74 (-3.9%)
Mutual labels:  vuex
Sluaunreal
lua dev plugin for unreal engine 4
Stars: ✭ 1,195 (+1451.95%)
Mutual labels:  plugin
Wordpress Plugin Construction
Tools 🧰 for developing and running WordPress websites
Stars: ✭ 73 (-5.19%)
Mutual labels:  plugin
Fcnpc
FCNPC - Fully Controllable NPC
Stars: ✭ 73 (-5.19%)
Mutual labels:  plugin
Vue2 Admin
基于vue-element-admin、Vue2 权限、监控、管理系统(包含地图等嵌套)
Stars: ✭ 74 (-3.9%)
Mutual labels:  vuex
React Antd Multi Tabs Admin
ts+react+antd-多页签后台模板(纯净版,非 antd pro!)
Stars: ✭ 73 (-5.19%)
Mutual labels:  tabs
Vue Mall
微信公众号测试项目
Stars: ✭ 74 (-3.9%)
Mutual labels:  vuex
Kanban Board
A sample application demonstrating a basic kanban board, seeded with vue-cli
Stars: ✭ 76 (-1.3%)
Mutual labels:  vuex
Flexiblelogin
A Sponge minecraft server plugin for second factor authentication
Stars: ✭ 73 (-5.19%)
Mutual labels:  plugin
Foxman
🍥 an extensible mock server
Stars: ✭ 76 (-1.3%)
Mutual labels:  plugin
Kubectl Cssh
A kubectl plugin to ssh into Kubernetes nodes within separate tmux panes
Stars: ✭ 76 (-1.3%)
Mutual labels:  plugin
Remove W3schools
Chrome extension to remove W3Schools results in google searches.
Stars: ✭ 73 (-5.19%)
Mutual labels:  plugin
Git Repo Watcher
A simple bash script to watch a git repository and pull upstream changes if needed.
Stars: ✭ 73 (-5.19%)
Mutual labels:  sync

vuex-multi-tab-state

Build Status npm codecov codebeat badge npm npm bundle size npm type definitions code style: prettier demo

This Vuex plugin allows you to sync and share the status of your Vue application across multiple tabs or windows using the local storage.

This repository has a gitter chat where you can ask questions and propose new features:

Gitter

Installation

vuex-multi-tab-state is available in npm and can be installed with the following command:

npm i vuex-multi-tab-state

Usage

Just import vuex-multi-tab-state and add it in the plugins list of your Vuex Store object.

import Vue from 'vue';
import Vuex from 'vuex';
import createMultiTabState from 'vuex-multi-tab-state';

Vue.use(Vuex);

export default new Vuex.Store({
  state: { ... },
  mutations: { ... },
  actions: { ... },
  getters: { ... },
  plugins: [
    createMultiTabState(),
  ],
});

You can check the example provided here

NuxtJS

Integrating the plugin in NuxtJS requires a little more effort than in Vue. First of all, we have to create a file inside the plugins directory.

// ~/plugins/multiTabState.client.js
import createMultiTabState from 'vuex-multi-tab-state';

export default ({ store }) => {
  createMultiTabState()(store);
};

Note that the filename must have the following format *.client.js. The next step is to add this plugin to NuxtJS in nuxt.config.js:

// nuxt.config.js
export default {
  ...
  plugins: [{ src: '~/plugins/multiTabState.client.js' }],
  ...
}

If you didn't name the file according to the specified format, you can add the plugin this way:

// nuxt.config.js
export default {
  ...
  plugins: [{ src: '~/plugins/multiTabState.client.js', mode: 'client' }],
  ...
}

Both ways tell NuxtJS that the plugin should only be run client-side (because the plugin uses window, not available server-side).

API

createMultiTabState({options})

Creates a new instance of the plugin with the given options. The possible options are as follows:

  • statesPaths Array<String>: contains the name of the states to be synchronized with dot notation. If the param is not provided, the whole state of your app will be sync. Defaults to [].

    Example: Only the oranges will be synchronized.

    export default new Vuex.Store({
      state: {
        fruits: {
          oranges: 0,
          apples: 0,
        },
      },
      plugins: [createMultiTabState({
        statesPaths: ['fruits.oranges'],
      })],
    });
    
  • key <String>: key of the local storage in which the state will be stored. Defaults to 'vuex-multi-tab'.

Test

The tests have been written with mocha and chai.

npm install
npm run test

Collaborate

npm collaborators

If you feel that something can be improved, go on, create a pull request! Please follow the programming style and document your changes correctly.

License

NPM

This project is under the MIT license. More information here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].