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

muou

v0.2.3

Published

可方便快捷的创建数据之间的变化响应,当数据发生变化时自动执行相关逻辑。 比如在更新视图时非常有用,只需要建立好视图与数据之间的关系。后面不再关心视图,而只需要处理好数据即可实现自动更新视图。 `注意:考虑性能方面采用了宏任务处理effect,所以当数据在同一时刻发生频繁改变,effect只会执行一次` # 安装

Downloads

11

Readme

提线木偶

可方便快捷的创建数据之间的变化响应,当数据发生变化时自动执行相关逻辑。 比如在更新视图时非常有用,只需要建立好视图与数据之间的关系。后面不再关心视图,而只需要处理好数据即可实现自动更新视图。 注意:考虑性能方面采用了宏任务处理effect,所以当数据在同一时刻发生频繁改变,effect只会执行一次

安装

npm install muou
yarn add muou

快速上手

import { state, effect } from 'muou';

// 初始化一个可检测式数据
const store = state({
    value: {},
    step: 1
});
// 当effect内数据发生变化时触发
const stopEffect = effect(() => {
    if (store.data.step == 2) {
        console.log(store.data.value);
    }
});
// 通过store.data获取数据
store.data.step ++;
// 直接修改引用
store.data.value = {a: 1};
// 当传入错误类型时自动转换成正确类型
store.data.value = '2' as any;
// 可在任何时刻,任何位置修改数据
setTimeout(() => {
    store.data.step = 1;
    store.data.value = {a: 2};
    // 停止数据响应
    stopEffect();
}, 1000);

状态管理

import { defineStore, ref, computed } from 'muou';

export default defineStore('user', () => {
    const id = ref(0);
    const username = ref('');

    const login = async (uname: string, password: string) => {
        id.value = 1000;
        username.value = uname;
        return data;
    }

    // 计算属性
    const idname = computed(() => {
        return id.value + username.value
    });

    return {
        id,
        username,
        idname,
        login
    };
});

其他地方使用状态

import user from './user';

effect(() => {
    console.log(user.idname);
})
// 模拟调用登陆方法
user.login('username', '123456');