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

easy-signals

v0.1.0

Published

Easy Signals is a signal library with no dependencies for node, deno and browsers.

Downloads

3

Readme

Easy Signals

Easy Signals is a signal library with no dependencies for node, deno and browsers based on the Angular Signals.

Table of Contents

Install

npm install easy-signals

Usage

Example on how to use Easy Signals:

NodeJs

import { signal, computed, effect } from 'easy-signals';

const count = signal(0);
const doubleCount = computed(() => count() * 2, count);
effect(() => console.log("effect called, count: ", count()), count);
console.log('doubleCount: ', doubleCount());
count.update((val) => val + 1);
console.log('doubleCount: ', doubleCount());
count.update((val) => val + 1);
console.log('doubleCount: ', doubleCount());
count.set(10);

Angular

HTML:

<p>Count is: {{ count() }}</p>
<p>Double Count is: {{ doubleCount() }}</p>
<button (click)="increment()">+1</button>

TypeScript:

import { signal, computed, effect } from 'easy-signals';

  count = signal(0);
  doubleCount = computed(() => count() * 2, this.count);

  increment() {
    this.count.update((val) => val + 1);
  }

Angular (without Zone.js)

HTML:

<p>Count is: {{ count() }}</p>
<p>Double Count is: {{ doubleCount() }}</p>
<button (click)="increment()">+1</button>

TypeScript:

import { signal, computed, effect } from 'easy-signals';

  count = signal(0);
  doubleCount = computed(() => count() * 2, this.count);

  constructor(private cdr: ChangeDetectorRef) {
    effect(() => {
      this.cdr.detectChanges();
    }, this.count, this.doubleCount);
  }

  increment() {
    this.count.update((val) => val + 1);
  }
import { getFile, uploadFilesTo } from 'easy-file-picker';

async getFile(): void {
  const file = await getFile();
  await uploadFilesTo("http://example.com", file);
}

Signal Types

Signal

Creates a new Signal with a intialValue, the value can be changes using the set, update and mutate functions.

function signal<T>(initialValue: T): Signal<T>

Computed

Creates a new ReadonlySignal where the value is the return of the computation function. The value is updates when the signals's values are updated.

function computed<T>(computation: () => T,...signals: ReadonlySignal<any>[]): ReadonlySignal<T>

Effect

The effectFn function is called everytime the values from signals are updated.

function effect(effectFn: () => void,...signals: ReadonlySignal<any>[]): void

Signal Functions

asReadonly

Transforms a Signal into a ReadonlySignal.

function asReadonly: () => ReadonlySignal<T>

set

Sets a new Signal value.

function set: (value: T) => void

update

Updates the Signal's value with the return of the updateFn function.

function update: (updateFn: (value: T) => T) => void

mutate

Can be used to mutate the Signal's value using the mutatorFn function.

function mutate: (mutatorFn: (value: T) => void) => void

Changelog

Version 0.1:

  • published library

FAQs

No FAQs for now. (⌐■_■)