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

vue-lazy-store

v1.0.1

Published

Vue state management plug-in,Simple version of vuex

Downloads

6

Readme

简介:一个简易版的vue状态管理包,支持完全体typescript。

Intro: Vue state management plug-in,Simple version of vuex,support typescript。

安装/Install

npm/cnpm install vue-lazy-store --save / yarn add vue-lazy-store

使用/Use

使用方法跟vuex类似,基本可以无缝切换.
Similar to vuex, it can be switched seamlessly.

store-ts
// src/store/index
import VueLazy from 'vue-lazy-store';
Vue.use(VueLazy);

class Text1 {
        public count: number = 0;
        public add(): number {
                return count ++;
        }
}

class BaseStore extends VueLazy.Store {
        public text1: Text1;
        public constructor() {
                super();
                this.text1 = new Text1();
                // 请在最后面激活store / Activate store at the end
                this.init();
        }
}

// ssr
export default BaseStore;
// csr
export default new BaseStore();

declare module 'vue/types/vue' {
	    interface Vue {
		        $store: BaseStore;
	    }
}

declare module 'vue/types/options' {
	    interface ComponentOptions<V extends Vue> {
		        store?: BaseStore;
	    }
}
store-js
import Vue from "vue";
import VueLazy from "vue-lazy-store";
Vue.use(VueLazy);

const text1 = {
        count: 0,
	add() {
		this.count++;
	}
}
const store = new VueLazy.Store({
	text1
});
store.init();

export default store;
.vue-ts
// support ts
import { Vue, Component, Watch } from 'vue-property-decorator';

@Component<LocalVue>({})
export default class LocalVue extends Vue {
        public get text1 () {
                return this.$store.text1;
        }
        public get count() {
               return this.text1.count; // 0
        }
        public mounted() {
                this.text1.add();
                console.log(this.count); // 1;
        }
}
.vue-js
computed: {
	text1() {
		return this.$store.text1;
	},
	count() {
		return this.text1.count;
	}
},
mounted() {
        this.text1.add();
	console.log(this.count); // 1;
}

ssr客户端接管状态 / ssr client takeover state

if (window.__INITIAL_STATE__) {
	store.replace(window.__INITIAL_STATE__);
 }

tips

状态变更上不像vuex那样严谨,需要commit状态为true时,才能更新。但是使用起来非常简单, 而且支持class写,进而完全支持ts,欢迎进一步完善。
State changes are not as rigorous as vuex, and they need to be true before they can be updated. But it's very simple to use. And support class writing, and then fully support ts, welcome to further improve

之前想好的easy,simple之类的词语,一律用不了,那就不如叫它懒人store吧!
Previously thought of easy, simple and other words, are no longer used, it would be better to call it lazy store!

example

demo