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

flyvar

v1.0.7

Published

F*** you, I only want to fly my Global variable! | 老子就想飞全局变量

Downloads

5

Readme

flyVar

F*** you, I only want to fly my Global variable!

Install

npm install flyvar

Use

I want to fly! I want to fly global variables freely! I also want to trigger some callbacks when the variables change!

import

import flyVar from 'flyvar';

initialize a storage

const store = new flyVar();

use a global variable

store.set('valueKey',yourGlobalVariable)
store.get('valueKey')

connect a global variable with a callback

Recommended Use.

**Note: When collocation with React Hook, pay attention to connect each function component only once, otherwise it may cause the connection every time it is re-rendered. One solution is to set a state and connect only when it is the initial value. **

store.connect('valueKey',()=>{
	//do something
},name)

When this variable update, this callback will be triggered.

set a global effect

(There may be a bug)

Do not use unless there is no other way.

store.effect(()=>{
	//do something
},name)

When a variable in this storage changed, this callback will be triggered.

When the callback function has the same name

Will replace the old with the new.

中文文档

老子就要飞全局变量,怎么滴?

安装

npm install flyvar

使用

老子就要飞!飞变量!全局的!痛快的飞!谁也***别想拦着我!

除此以外,我还想在飞全局变量的时候触发一些回调。

导入

import flyVar from 'flyvar';

初始化一个存储库

const store = new flyVar;

使用全局变量

store.set('valueKey',yourGlobalVariable)
store.get('valueKey')

将全局变量与一个回调连接

推荐使用。

注意:在与 React Hook 搭配的时候,注意在每个函数组件只连接一次,否则可能会导致每次重新重新渲染的时候都连接。一个解决的办法是设置一个state,只在为初始值时连接。

store.connect('valueKey',()=>{
	//do something
},name)

当这个全局变量的值改变,回调会被触发。

设置全局效果

(可能存在bug)

不到万不得已不要使用。

store.effect(()=>{
	//do something
},name)

当任何一个全局变量的值改变,回调会被触发。

当回调函数重名时

会以新的取代旧的。