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-depot

v0.6.0

Published

Simple state manager based and for Vue with support for vue-devtools. ### Installation ``` npm install vue-depot ``` ### Usage

Downloads

20

Readme

vue-depot

Simple state manager based and for Vue with support for vue-devtools.

Installation

npm install vue-depot

Usage

Creating state manager

//store.ts
import {Depot, Store, module} from 'vue-depot';
@Store(true)
class RootStore extends Depot {
    public lastUpdate: Date = new Date();
    public todos: string[] = [];
    get todosCount(): number {
        return this.todos.length;
    }
    public addTodo(text: string) {
        this.todos.push(text);
    }
    public async asyncAddTodo(test: string) {
        return Promise((r) => {
            setTimeout(() => {
                this.addTodo(test);
                r();
            }, 1000)
        });
    }
}
export const BaseStore = new RootStore();

Usage in other file

import {BaseStore} from './store.ts'
new Vue({
    data() {
        return {
            store: BaseStore
        };
    },
    computed: {
        todosList() {
            return this.store.todos.join();
            // or return BaseStore.todos.join();
        }
    },
    methods: {
        add() {
            this.store.addTodo('newTodo');
            // or BaseStore.addTodo('newTodo');
            // or @click="store.addTodo('newTodo')" inside template
        }
    }
})

@Store(isRootInstance?: boolean)

  • isRootInstance - needed only for vue-devtools to recognise root instance and emit "init" event.

Convert given class to Vue component so new instance is in fact new Vue component with full support of features like smart getters, reactive props and methods like $watch. Decorator also inject state getter/setter required for vue-devtools (extending with Depot is optional and only add typings for .state)

Modules

It is possible to nesting instances in this way:

@Store()
class User { ...some props and actions }
@Store(true)
class RootStore extends Depot {
    @module(User)
    public user: User = new User();
    @module(User)
    public userList: User[] = [];
}
export const BaseStore = new RootStore();

IMPORTANT!!! Remember to manipulate with Arrays like in Vue: use Vue.set(BaseStore.userList, 0, value) instead of BaseStore.userList[0] = value;

@module(moduleClass: T)

  • moduleClass - necessary for casting raw object into module. Define nested module

Depot

Depot.state

Setter/getter to get or set raw-data model. Mainly used by vue-devtools and may be expensive. It support module instances casting so raw object will be converted to module object (but only for modules).