npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lue

v1.0.1

Published

Vue and vuex based library, writing less verbose code.

Downloads

14

Readme

js-standard-style build pass npm-version license

lue

:seedling: 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