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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dynapp/wc-api-generic

v1.1.3

Published

Generic vuex store api

Downloads

11

Readme

Web Components API Generic

Example

Direct in store/index.js

store/index.js

import Vue from 'vue'
import Vuex from 'vuex'
import { createModule } from '@dynapp/wc-api-generic'

Vue.use(Vuex);

export default new Vuex.Store({
  modules: {
    <module>: createModule({
      entitySingular: '<module_item_singular>',
      entityPlural: '<module_item_plural>'
    })
  }
});

Separate module file

store/modules/<module>.js

import { createModule } from '@dynapp/wc-api-generic'

export default createModule({
  entitySingular: '<module_item_singular>',
  entityPlural: '<module_item_plural>'
});

store/index.js

import Vue from 'vue'
import Vuex from 'vuex'
import <module> from './modules/<module>'

Vue.use(Vuex);

export default new Vuex.Store({
  modules: {
    <module>
  }
});

Getters

items

Get list of items.

this.$store.getters['<module>/items']

getItemById

Get an item by its id.

Getter is callable with the id as parameter.

this.$store.getters['<module>/getItemById'](<id>)

filterItems

Get a filtered list of items.

Getter is callable with the filter function as parameter.

this.$store.getters['<module>/filterItems'](<filter_function>)

getAttachmentUrl

Get attachment url.

Returns null If the attachment does not exist.

Getter is callable with the id and attachment name as parameters.

this.$store.getters['<module>/getAttachmentUrl'](<id>, <attachment>)

getUploadProgressById

Get upload progress for s specific item.

Returns a percentage, 0 - 100.

Returns null if no upload progress exists for the given id.

this.$store.getters['<module>/getUploadProgressById'](<id>)

getDownloadProgressById

Get download progress for s specific item.

Returns a percentage, 0 - 100.

Returns null if no download progress exists for the given id.

this.$store.getters['<module>/getDownloadProgressById'](<id>)

newId

Get id generator.

Returns a function for generating new ids.

this.$store.getters['<module>/newId']

Mutations

setItems

this.$store.commit('<module>/setItems', <items>)

addItem

this.$store.commit('<module>/addItem', <item>)

replaceItem

this.$store.commit('<module>/replaceItem', <item>)

replaceItems

this.$store.commit('<module>/replaceItems', <items>)

removeItem

this.$store.commit('<module>/removeItem', <id>)

setUploadProgress

Takes a payload with id and value.

this.$store.commit('<module>/setUploadProgress', <payload>)

unsetUploadProgress

this.$store.commit('<module>/unsetUploadProgress', <id>)

setDownloadProgress

Takes a payload with id and value.

this.$store.commit('<module>/setDownloadProgress', <payload>)

unsetDownloadProgress

this.$store.commit('<module>/unsetDownloadProgress', <id>)

Actions

createItem

Create an item. Makes a request to the server then adds the item to the store.

Returns a Promise to be able to act once the action is completed.

this.$store.dispatch('<module>/createItem', <item>)

updateItem

Update an existing item. Makes a request to the server then updates the item in the store.

Returns a Promise to be able to act once the action is completed.

this.$store.dispatch('<module>/updateItem', <item>)

updateItems

Update multiple existing items. Makes a request to the server then updates the items in the store.

This action does not support attachments.

Returns a Promise to be able to act once the action is completed.

this.$store.dispatch('<module>/updateItems', <items>)

fetchItems

Fetches a list of items and save them to the store.

Returns a Promise to be able to act once the action is completed.

this.$store.dispatch('<module>/fetchItems')

fetchItemById

Fetches a single item and saves it to the store.

Returns a Promise to be able to act once the action is completed.

this.$store.dispatch('<module>/fetchItemById', <id>)

deleteItem

Delete an existing item. Makes a request to the server then updates the store.

Returns a Promise to be able to act once the action is completed.

this.$store.dispatch('<module>/deleteItem', <id>)

cloneItem

Clone an existing item. Makes a request to the server then updates the store.

Returns a Promise to be able to act once the action is completed.

this.$store.dispatch('<module>/cloneItem', <id>)