:seedling: Vue and vuex based library, writing less verbose code.

Overview

js-standard-style build pass npm-version license

lue

🌱 Vue and vuex based library, writing less verbose code.

Installation

Install the pkg with npm:

npm install lue --save

or yarn

yarn add lue

Basic Uasage

1. create a module

// counter.js
export default {
    namespace: 'counter',
    state: {
        count: 0,
        title: 'Counter'
    },
    actions: {
        increase ({dispatch, state}, payload) {
            const val = state.count + 1;
            // should be return a object to update state
            // if return undefined or not a object, state won't be updated 
            return {
                count: val
            };
        },
        decrease ({dispatch, state}, payload) {
            const val = state.count - 1;         
            return {
                count: val
            };
        }
    }  
};

2. export all modules as a object

// modules/index.js
import counter from 'path/to/counter';
import other from 'path/to/other';

export default {
    counter,
    other
};

3. create vue router options

// options/index.js
const App = () => import(/* webpackChunkName: "app" */ 'path/to/app/index.vue');
const Counter = () => import(/* webpackChunkName: "counter" */ 'path/to/counter/index');

const Outer = { template: '<router-view></router-view>' };

export default {
    mode: 'history',
    routes: [
        {
            path: '/',
            component: Outer,
            children: [
                { path: '', component: App },
                { path: 'counter', component: Counter },
                // other config
            ]
        }
    ]
}

4. create your app

import Vue from 'vue';
// path/to/index.js
import Lue from 'lue';

import modules from 'path/to/modules/index';
import routerOptions from 'path/to/options/index';
import filters from 'path/to/filter/index';

// 1. install plugin
Vue.use(Lue);

// 2. new a lue instance
const app = new Lue();

// 3. create store
app.createStore(modules);

// 4. init router
app.initRouter(routerOptions);

// 5. start your application
app.start('#app', {
    // optional options object
    filters,
    // env/vue-i18n.etc
});

5. combine lue with vue components

<template>
    <div class="counter">
        <h3>{{title}}:</h3>
        <div>
            <span class="decrease" @click="sub">-</span>
            <span>{{count}}</span>
            <span class="increase" @click="add">+</span>
        </div>
    </div>
</template>

<script>
    import { mergeActions, mergeProps } from 'lue';

    export default {
        computed: {
            ...mergeProps(['counter.count', 'counter.title'])
            // or
            // ...mergeProps({
            //    test: 'counter.title',
            // })
        },

        methods: {
            ...mergeActions(['counter.increase', 'counter.decrease']),
            add () {
                this.increase();
            },

            sub () {
                this.decrease();
            }
        }
    }
</script>

Lue Instance Properties

.store: Object

Vuex store instance.

.router: Object

Vue router instance.

.options: Object

Lue constructor options.

Lue Instance Methods

.createStore(modules: Object, opts?: Object)

Create vuex store. See opts.

.initRouter(routerOptions: Object)

Init vue-router instance. See routerOptions

.start(el: String, opts?: Object)

Start the app. See opts of creating a vue instance. el is a css selector for document.querySelector

Examples

Running the examples:

npm install
npm run dev # serve examples at localhost:8000

LICENSE

MIT

You might also like...
Simple counter with Vue.js and Vuex as state management

vuex-counter Project setup npm install Compiles and hot-reloads for development npm run serve Compiles and minifies for production npm run build Li

💾 Persist and rehydrate your Vuex state between page reloads.
💾 Persist and rehydrate your Vuex state between page reloads.

vuex-persistedstate Persist and rehydrate your Vuex state between page reloads. Install npm install --save vuex-persistedstate The UMD build is also a

Vuex binding for client-side search with indexers and Web Workers :green_book::mag:
Vuex binding for client-side search with indexers and Web Workers :green_book::mag:

Vuex Search is a plugin for searching collections of objects. Search algorithms powered by js-worker-search. See working example here. Installation: n

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

vuex-multi-tab-state This Vuex plugin allows you to sync and share the status of your Vue application across multiple tabs or windows using the local

Vuex state persistance and synchronization between tabs/windows.

vuex-basement Vuex state persistance and synchronization between tabs/windows. Tested to work with Vue2. One Shortcomming (please read before use). Th

:hammer: Utilities for vuex to easily create and manage actions.

vuex-action Utilities for vuex to easily create and manage actions. Allow you to create untyped action Support for Promise Work with [email protected] and [email protected] I

☘️ A package that dynamically registers your components and vuex modules
☘️ A package that dynamically registers your components and vuex modules

Vue Registrar A dynamic component registrar and Vuex module assembler A Vue.js package that makes your code a lot cleaner and much more understandable

sample repo to compare vuex and provide/inject

my-sample Project setup yarn install Compiles and hot-reloads for development yarn serve Compiles and minifies for production yarn build Lints and

Use Vuex and V-Router

TrafficLights Project setup npm install Compiles and hot-reloads for development npm run start Compiles and minifies for production npm run build C

Owner
Pomy
:blush: :smiling_imp: :sunglasses: I hear and I forget. I see and I remember. I do and I understand. Follow heart, Try everything :running: :sunny: :dog:
Pomy
Reduce async boilerplate code generating Vuex modules. Compatible with Vue 2.x.

vuex-async-module Reduce async boilerplate code generating Vuex modules. Compatible with Vue 2.x Installation npm install @liqueflies/vuex-async-mod

Lorenzo Girardi 15 Mar 26, 2021
Todos-VUEX - A todo list made using Vue, Vuex, Axios and JSON Placeholder API.

todos Project setup npm install Compiles and hot-reloads for development npm run serve Compiles and minifies for production npm run build Lints and

Lasanja 0 Jan 3, 2022
vuex-module-generator - It allows you to create a vuex module easily.

Vuex Module Generator (VMG) VMG allows you to create a vuex module easily. See All implementations. See Customer Example. Supported module types Clone

Abdullah 91 Dec 28, 2022
The Vuex plugin to enable Object-Relational Mapping access to the Vuex Store.

Vuex ORM ?? HEADS UP! Currently, Vuex ORM Next project is on going, and we are hoping it is going to be the foundation of the version 1.0.0 release. W

Vuex ORM 2.4k Dec 29, 2022
Lightweight vuex inspired centralized state management library for all kinds of javascript applications. Great for React Native.

Verx Lightweight vuex inspired centralized state management library for all kinds of javascript applications. install npm install --save verx # yarn a

Jaynti Kanani 3 Nov 4, 2019
Bryce Soghigian 1 May 18, 2021
A project to demonstrate the use of Store and state, getters, mutations in Vuex and VueJS

Vuex State Sample ?? ?? A project to demonstrate the use of Store and state, getters, mutations in Vuex and VueJS. Create Vuex Store and use it to hol

Yufenyuy Veyeh Didier 0 Apr 13, 2020
Modular security for Vue, Vuex, Vue-Router and Nuxt

vue-kindergarten Introduction vue-kindergarten is a plugin for VueJS 2.0 that integrates kindergarten into your VueJS applications. It helps you to au

Jiří Chára 309 Dec 8, 2022
📦 Fast, Simple, and Lightweight State Manager for Vue 3.0 built with composition API, inspired by Vuex.

v-bucket NPM STATUS: ?? Fast, Simple, and Lightweight State Management for Vue 3.0 built with composition API, inspired by Vuex. Table of Contents Mai

mehdi 42 Aug 10, 2022
Vue and Vuex plugin to persistence data with localStorage/sessionStorage

vuejs-storage Vue.js and Vuex plugin to persistence data with localStorage/sessionStorage Purpose This plugin provide a simple binding with localStora

maple 119 Dec 15, 2022