All Projects → kenberkeley → Vue State Management Alternative

kenberkeley / Vue State Management Alternative

Vuex state management alternative for both Vue 1.x & 2.x

Projects that are alternatives of or similar to Vue State Management Alternative

Vuex Pathify
Vue / Vuex plugin providing a unified path syntax to Vuex stores
Stars: ✭ 1,281 (+1811.94%)
Mutual labels:  vuex, state-management
Vuex
🗃️ Centralized State Management for Vue.js.
Stars: ✭ 27,115 (+40370.15%)
Mutual labels:  vuex, state-management
Xsm
State Management made eXtraordinarily simple and effective for Angular, React, and Vue
Stars: ✭ 138 (+105.97%)
Mutual labels:  vuex, state-management
Vue Entity Adapter
Package to maintain entities in Vuex.
Stars: ✭ 20 (-70.15%)
Mutual labels:  vuex, state-management
Vue Class Store
Universal Vue stores you write once and use anywhere
Stars: ✭ 243 (+262.69%)
Mutual labels:  vuex, state-management
Duix
A State Manager focused on KISS and Pareto's Principle
Stars: ✭ 48 (-28.36%)
Mutual labels:  vuex, state-management
Vue Meitu
vue仿手机版美图手机官网
Stars: ✭ 59 (-11.94%)
Mutual labels:  vuex
Xz Admin
基于Vue、element-ui技术栈开发的前后端分离后台管理系统(持续维护中)
Stars: ✭ 62 (-7.46%)
Mutual labels:  vuex
Muster
A universal data layer for components and services
Stars: ✭ 59 (-11.94%)
Mutual labels:  state-management
Mall Admin Web
mall-admin-web是一个电商后台管理系统的前端项目,基于Vue+Element实现。 主要包括商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等功能。
Stars: ✭ 9,123 (+13516.42%)
Mutual labels:  vuex
Vue
Stars: ✭ 65 (-2.99%)
Mutual labels:  vuex
Vue2 Axf
爱鲜蜂商城项目代码
Stars: ✭ 64 (-4.48%)
Mutual labels:  vuex
Vue Login
vue2 express register login
Stars: ✭ 61 (-8.96%)
Mutual labels:  vuex
Genal Chat
🐱‍🏍阿童木聊天室 nestjs+vue全栈聊天室 前后端分离 typescript一把梭
Stars: ✭ 1,105 (+1549.25%)
Mutual labels:  vuex
Simple Todo Tutorial
Simple todo app built with Vue 2.0 and Vuex 2.0
Stars: ✭ 62 (-7.46%)
Mutual labels:  vuex
Vue Mobile Mint
🍔 🍖 🍴基于mint-ui的饿了么外卖平台混合app(仿饿了么)
Stars: ✭ 59 (-11.94%)
Mutual labels:  vuex
Vue Cnode
基于vue2 + vue-router + vuet + ES6 + less + flex.css重写vue版cnode社区,使用webpack2打包
Stars: ✭ 1,134 (+1592.54%)
Mutual labels:  vuex
Vue Music Qq
A qq-music project is based on vue-cli. The pages are simple and smooth
Stars: ✭ 58 (-13.43%)
Mutual labels:  vuex
Vue Todo List
vue2.0+vuex+localStorage 待办事项
Stars: ✭ 61 (-8.96%)
Mutual labels:  vuex
Basic Vue Chat
Easy to use Vue chat.
Stars: ✭ 64 (-4.48%)
Mutual labels:  vuex

Alternative state management for Vue

Chinese README - 中文说明

.sync is deprecated in Vue 2.x (UPDATE: a castration edition is back in v2.3)
Especially for the case that props passed shallowly, you have to write more verbose code
The docs mentioned using v-model as a hack which sounds hardly elegant
Also, the official solution Vuex is not suitable for independent components
We all know one-way data flow is a best practice
but development efficiency, maintainability, simple and straight-forward should all be taken into consideration

After reviewing the below contents of the docs:

We can implement an awesome state management solution ourselves

Firstly, Take a look at src/sharedState.mixin.js:

// The magic of state persistance is closure here
export const sharedState = {
  todos: [],
  counter: 0
}

export const resetTodos = () => sharedState.todos = []
export const resetCounter = () => sharedState.counter = 0
export const addTodo = (s) => sharedState.todos.push(s)
export const inc = () => sharedState.counter++
export const dec = () => sharedState.counter--

/**
 * @exports.default {Mixin}
 */
export default {
  data: () => ({
    sharedState
  }),
  methods: {
    resetTodos,
    resetCounter,
    addTodo,
    inc,
    dec
  }
}

/*

  You can access the shared state and methods
  not only within Vue component (as mixins) but also in common js files

  ※ e.g.
  import { sharedState, inc } from '<path to>/sharedState.mixin'
  
  console.info(sharedState.counter) // 0
  inc()
  console.info(sharedState.counter) // 1
 
 */

Then, apply to the component tree below:

App
 ├─ Child1
 |    └─ Grandchild1
 └─ Child2
      └─ Grandchild2

Finally we get an online demo

It's highly suggested to dive into src/ to learn about how to use it
This solution is applicable for Vue 1.x / 2.x


Test it yourself

$ git clone https://github.com/kenberkeley/vue-state-management-alternative.git
$ cd vue-state-management-alternative
$ npm i
$ npm start
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].