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

@enzoaicardi/reactivity

v0.1.5

Published

A small modular interface for using signals in javascript

Downloads

36

Readme

Reactivity.js

A small modular interface for using signals in javascript

NPM Version NPM Downloads Bundle Size JSDelivr Hits Wiki

What is a signal ?

Largely inspired by the tc39 specification proposal

A signal is an object that represents a state, and has methods for retrieving the current state (reading the value) and methods for changing the state (writing the value).

When a signal's state is read, it retrieves the parent context and adds it to its dependencies. It can then update all its dependencies when its state changes.

Signals are often the most stable and easiest way to dynamically update data at no cost.

If this description sounds complicated, in practice using a signal is very simple. Here is a demonstration:

// setup a signal (named counter) and a reactive function (named counterLog)
const counter = new Signal(0);
const counterLog = new Reactive(() => console.log(counter.get()));

// activate counterLog
counterLog.use(); // this will trigger counterLog and print "0" in the console
// or...
counterLog.add(counter); // this will manually add counterLog to counter dependencies

counter.set(1); // this will trigger counterLog and print "1" in the console
counter.set(counter.value + 2); // this will trigger counterLog and print "3" in the console

counterLog.use(); // this will trigger counterLog and print "3" in the console

List of all exports

import {
    Signal, // used to create a signal
    ComputedSignal, // used to create a computed signal
    Reactive, // used to create a reactive function
} from "@enzoaicardi/reactivity"; // cdn at https://cdn.jsdelivr.net/npm/@enzoaicardi/reactivity@latest/esm/reactivity.js

Intallations

NPM package

npm install @enzoaicardi/reactivity
import { ... } from "@enzoaicardi/reactivity"; // es modules
const { ... } = require("@enzoaicardi/reactivity"); // commonjs modules

CDN import

// es modules
import { ... } from "https://cdn.jsdelivr.net/npm/@enzoaicardi/reactivity@latest/esm/reactivity.js";
<!-- iife function execution -->
<script src="https://cdn.jsdelivr.net/npm/@enzoaicardi/reactivity@latest/iife/reactivity.js"></script>
<script>
    // global object destructuration
    const { ... } = Reactivity;
</script>