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

mayako-wex

v0.3.5

Published

新建一个文件为store.js 内容为 ``` javascript /** * no use strict */ wx.wex = new Wex().init({ state: { obj: '咩咩咩咩', TS: 2, peopleNum: 0, dishesTypeId: 1, dishesTypeName: '', test:{ a:1, b:{a:2} } },

Downloads

5

Readme

使用方法

初始化&引入

新建一个文件为store.js 内容为

/**
 * no use strict 
 */
wx.wex = new Wex().init({
  state: {
    obj: '咩咩咩咩',
    TS: 2,
    peopleNum: 0,
    dishesTypeId: 1,
    dishesTypeName: '',
    test:{
      a:1,
      b:{a:2}
    }
  },
  Mutation: {
    getFoodInfo: () => {

    },
    setTest:({setState,args})=>{
      setState('test',args[0])
    },
    getTest:({state})=>{
      return state.test;
    },
    getdishesTypeId: ({state}) => {
      return state.dishesTypeId
    },
    setdishesTypeId: ({setState,args}) => {
      setState('dishesTypeId', args[0] );
    },
    setdishesTypeName: ({setState,args}) => {
      setState('dishesTypeName', args[0] );
    },
    getdishesTypeName: ({state}) => {
      return state.dishesTypeName;
    },
    getObj: ({state}) => {
      return state.obj
    },
    tt: ({state}) => {
      return state.TS
    },
    setTs: ({setState,args}) => {
      setState('TS', args[0])
      
    },
    setObj: ({setState,commit,args}) => {
      setState('obj', args[0])
      commit('setTs',args[0])
    },
    setPeopleNum: ({setState,args,state}) => {
      state.peopleNum = args[0]
      // setState('peopleNum', args[0] )
    },
    getPeopleNum: ({state}) => {
      return state.peopleNum
    }

  }
});

在入口文件中引入

import './store'

在需要使用的地方

// 如果只是需要使用获取值,设置值
    var {
        setPeopleNum,
        getTest,
        setTest
    } = wx.wex.mapMutations;
setPeopleNum(10)
    var {
        peopleNum
    } = wx.wex.state
// 如果需要是值具有响应功能
wx.wex.on('dishesTypeId', (oj) => {
     this.dishesTypeId = oj;
}, this)
// 使用箭头函数保证作用域指向,在回调填写响应后的变化
// 同一页面内多次订阅同一状态会只记录最后一次订阅,防止多次无意义订阅造成内存泄漏
// 无法直接更改state和mutation,使用wx.wex.history可以查询到全部的变更记录
// 新增部分数组变异方法,在Mutation里直接操作state也可以观测到变化,不过setState在某些情况下性能更好一些。

wex对象提供state(取值),commit(提交方法),on(订阅),emit(触发),off(删除),mapMutations(映射mutations方法),history(变更记录)几个方法

在mutaions里参数包含state,setState,commit,args4个参数。