Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-store-vuex-sync

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-store-vuex-sync

auto sync electron-store and vuex

  • 1.0.1
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Electron-store-vuex-sync

自动同步electron-storevuex

使用方法

在background.js中(node进程)

const { ipcMain } = require('electron')
const Store = require('electron-store');
const { injectStore } = require('electron-store-vuex-sync')
const store = new Store();

injectStore(ipcMain, store)

在创建vuex的地方

import Vuex from 'vuex'
import { getVuexStoreConfig } from 'electron-store-vuex-sync'
import { ipcRenderer } from 'electron'

const store = new Vuex.Store(getVuexStoreConfig(ipcRenderer))
return store

参数

injectStore

  • ipcMain electronipcMain用来注入监听事件
  • store electron-store创建的store
  • [storeName] 当前这个store的名字需要不同页面同步不同store的时候需要,可选

返回传入的store

getVuexStoreConfig

  • ipcRenderer electronipcRenderer用来注入监听事件
  • [schema] electron-storeschema可以根据这个自动初始化,省去手动的问题
  • [storeName] 当前这个store的名字需要不同页面同步不同store的时候需要,可选

其他的事

  1. 如果使用schema来初始化的话,vuexmutationset:schema的key

  2. 只会生成对应的vuex配置,像是state,action这些你可以通过解构等方法把自己的方法注入进去

  3. 因为electron-store默认名字为config,所以vuex用来初始化和同步的事件前缀也默认为config:

  4. background的注入请放在最顶上

FAQs

Package last updated on 11 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc