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

koxr

v1.0.6

Published

react状态管理库

Readme

koxr

react状态管理库

API

observable

参数为非数组, 普通observable变量;

const observableValue = observable(0);

定义一个初始值为0的observable变量

observableValue(1);

observableValue set操作, 异步更新该变量的观察者, 前后两次set同一个值不会更新

observableValue();

observableValue get操作

参数为数组, 在普通observable变量上扩展['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift']等方法;

const observableArray = observable([]);
observableArray.push(0);
observableArray.push(1);
observableArray(); //[0, 1]

autorun

const destory = autorun(() => {
    console.log(observableValue())
});

observableValue 进行set操作, 都会触发log方法, 执行destory方法终止观察,一般处理副作用

computed

const computedValue = computed(() => {
    return observableValue() + 1;
})

observableValue 进行set, 会重新计算computedValue的值并缓存, computedValue get操作不会重新计算, 一般用作计算响应值

when

const destory = when(() => {
    //
}, () => {
    console.log(observableValue());
})

observableValue set操作, 会计算参数一的值为true时,执行参数二方法; destory执行终止观察

observer

class App extends Component {
    render() {
        return <div>{observableValue()}</div>;
    }
}
export default observer(App);

参数为class

observer(() => {
    return <div>{observableValue()}</div>;
});

参数为function

observableValue set操作自动更新组件