All Projects → ejfrancis → Vuex-Alt

ejfrancis / Vuex-Alt

Licence: MIT License
An alternative approach to Vuex helpers for accessing state, getters and actions that doesn't rely on string constants.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vuex-Alt

Tinystate
A tiny, yet powerful state management library for Angular
Stars: ✭ 207 (+1280%)
Mutual labels:  flux, state-management
redux-reducer-async
Create redux reducers for async behaviors of multiple actions.
Stars: ✭ 14 (-6.67%)
Mutual labels:  flux, flux-architecture
Smitty
Tiny flux implementation built on mitt
Stars: ✭ 210 (+1300%)
Mutual labels:  flux, flux-architecture
RxReduxK
Micro-framework for Redux implemented in Kotlin
Stars: ✭ 65 (+333.33%)
Mutual labels:  flux, state-management
react-workshops
Online react workshops
Stars: ✭ 36 (+140%)
Mutual labels:  flux, flux-architecture
Goes
Go Event Sourcing made easy
Stars: ✭ 144 (+860%)
Mutual labels:  flux, flux-architecture
fluxy
Fluxy is a Flux architecture implementation written in Kotlin.
Stars: ✭ 25 (+66.67%)
Mutual labels:  flux, flux-architecture
Juicr.js
A simple (and tiny <1kb) redux inspired reducer for handling state changes.
Stars: ✭ 102 (+580%)
Mutual labels:  flux, state-management
temperjs
State management for React, made simple.
Stars: ✭ 15 (+0%)
Mutual labels:  flux, state-management
AndroidFluxPractice
Android Flux Practice
Stars: ✭ 51 (+240%)
Mutual labels:  flux, flux-architecture
Stockroom
🗃 Offload your store management to a worker easily.
Stars: ✭ 1,745 (+11533.33%)
Mutual labels:  flux, state-management
react-evoke
Straightforward action-driven state management for straightforward apps built with Suspense
Stars: ✭ 15 (+0%)
Mutual labels:  flux, state-management
Fluxcapacitor
This is what makes the Flux design pattern possible.
Stars: ✭ 126 (+740%)
Mutual labels:  flux, flux-architecture
Firedux
🔥 🐣 Firebase + Redux for ReactJS
Stars: ✭ 148 (+886.67%)
Mutual labels:  flux, flux-architecture
Nucleo
🏋️‍♀️ Nucleo is a strongly typed and predictable state container library for JavaScript ecosystem written in TypeScript
Stars: ✭ 109 (+626.67%)
Mutual labels:  flux, state-management
nanoflux-fusion
Redux-like extension for Nanoflux
Stars: ✭ 15 (+0%)
Mutual labels:  flux, flux-architecture
Freezer
A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
Stars: ✭ 1,268 (+8353.33%)
Mutual labels:  flux, state-management
Hover
A very lightweight data store with action reducers and state change listeners.
Stars: ✭ 97 (+546.67%)
Mutual labels:  flux, flux-architecture
fluxiny
~1K implementation of flux architecture
Stars: ✭ 77 (+413.33%)
Mutual labels:  flux, flux-architecture
mutable
State containers with dirty checking and more
Stars: ✭ 32 (+113.33%)
Mutual labels:  flux, state-management

Vuex-Alt

An alternative, opinionated approach to Vuex helpers for accessing state, getters and actions that doesn't rely on string constants.

Installation

First install the npm package with

npm install --save vuex-alt

Then use the plugin, passing in the Vuex Store.

import Vuex from 'vuex';
import { VuexAltPlugin } from 'vuex-alt';

// use Vuex as usual
Vue.use(Vuex);

// create your store
const store = new Vuex.Store({ ... });

// use the VuexAltPlugin, and pass it
// the new Vuex Store
Vue.use(VuexAltPlugin, { store });

Prerequisites

Vuex-Alt makes two intentional, opinionated assumptions about your Vuex code:

  1. Mutations are only commited from within actions. Components never directly commit mutations. Every mutation has an accompanying action.
  2. All Vuex state, getters and actions are organized into Vuex modules.

These two rules lead to more scalable state management code, and more predictable state changes.

API Usage

Vuex-Alt provides an alternative approach to the Vuex helpers for mapState, mapActions, and mapGetters.

The main difference between the Vuex-Alt helpers and the original Vuex helpers is that instead of accepting strings to specify the namespace and action/getter you want, access is done via functions and nested objects.

mapState()

Provide an object that maps local Vuex instance properties to Vuex module properties.

For example, if you have a state property called count on a Vuex store module called counter you would access it like this:

computed: {
  ...mapState({
    count: (state) => state.counter.count
  })
}

mapActions()

Provide an object that maps local Vuex instance methods to Vuex module methods.

For example, if you have an action called increment() on a Vuex store module called counter you would access it like this:

methods: {
  ...mapActions({
    increment: (actions) => actions.counter.increment
  })
}

Now you can access it in your component via this.increment(10).

mapGetters()

Provide an object that maps local Vuex instance properties to Vuex module getters.

For example, if you have a getter called countPlusTen() on a Vuex store module called counter you would access it like this:

computed: {
  ...mapGetters({
    countPlusTen: (getters) => getters.counter.countPlusTen
  })
}
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].