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 🙏

© 2026 – Pkg Stats / Ryan Hefner

solid2-effector

v0.0.5

Published

Async effect, memo, and experimental writable signal primitives for Solid 2

Readme

solid2-effector

Async-aware effects, memos, and writable signals for Solid 2. Each asynchronous source tracks its reactive dependencies independently. Once all current sources have resolved, a synchronous derivation runs; unrelated derivation dependencies can update without refetching.

createAsyncSignal is experimental.

Installation

npm install [email protected]

Requires solid-js 2 (^2.0.0-rc.17). Create these primitives inside a Solid reactive owner (for example, a component or createRoot).

Usage

import { createSignal } from "solid-js";
import { createAsyncEffect, createAsyncMemo, createAsyncSignal } from "solid2-effector";

const [userId, setUserId] = createSignal(1);
const [teamId, setTeamId] = createSignal(7);
const [uppercase, setUppercase] = createSignal(false);

// These functions are application-provided; each returns a Promise.
const sources = [
  () => fetchUser(userId()),
  () => fetchTeam(teamId())
] as const;

const derive = ([user, team]: [User, Team]) => {
  const name = `${user.name} — ${team.name}`;
  return uppercase() ? name.toUpperCase() : name;
};

// Effect: apply a result, optionally returning a cleanup function.
createAsyncEffect(sources, derive, value => {
  console.log(value);
});

// Memo: read the derived result reactively.
const label = createAsyncMemo(sources, derive);

// Signal: read and manually update the derived result.
const [draft, setDraft] = createAsyncSignal(sources, derive);
setDraft("Custom label");
setDraft(previous => (previous ?? "") + "!");

These are three independent instances: they do not share requests. Within each instance, changing userId() reruns only its user source; changing uppercase() reruns only the synchronous derivation.

Initial loading and errors

createAsyncMemo and createAsyncSignal throw Solid 2's NotReadyError when read before their first value is ready. In a Solid component, <Loading> can show a fallback until the initial dependencies settle:

import { Loading, Errored } from "solid-js";

<Errored fallback={error => <p>{String(error())}</p>}>
  <Loading fallback={<p>Loading…</p>}>
    {label()}
  </Loading>
</Errored>

After the first successful result, an async memo retains its last value during revalidation. The async signal also supports direct writes while pending. Initial failures can be handled with <Errored>; use onError for diagnostic reporting.

Writable signal precedence

By default, createAsyncSignal uses native-style setter precedence: a pending derivation may overwrite a manual write when it resolves. Choose preserve to prevent an already in-flight request from replacing the manual value:

const [value, setValue] = createAsyncSignal(sources, derive, {
  writePolicy: "preserve"
});

A later dependency change may still derive a new value. Native-style precedence is not identical to Solid's entire scheduling behavior: a manual write during initial loading may reveal the value inside <Loading> earlier than a native writable derived signal.

API and TypeScript

Each source is () => T | PromiseLike<T>. Sources form a tuple, so TypeScript infers the corresponding resolved values in derive.

type AsyncSource<T> = () => T | PromiseLike<T>;
type Resolved<S extends readonly AsyncSource<any>[]> = {
  -readonly [K in keyof S]: Awaited<ReturnType<S[K]>>;
};
type Equality<T> = false | ((previous: T, next: T) => boolean);

createAsyncEffect(sources, derive, apply, options?): void;
createAsyncMemo(sources, derive, options?): () => Result;
createAsyncSignal(sources, derive, options?): [get, set];

derive(values) must be synchronous. apply(result) may return a cleanup function; other return values are ignored. The async signal setter accepts either a direct result or an updater (previous: Result | undefined) => Result and returns the assigned value.

| Option | Supported by | Purpose | | --- | --- | --- | | sourceEquals | All three | false (default), a comparator, or a per-source comparator tuple. Skip recomputation if newly resolved inputs are equivalent. | | resultEquals | All three | false (default) or comparator. Suppress equivalent derived results. | | onError(error, info) | All three | Report source, derivation, or application errors. info.stage and optional info.sourceIndex identify the failure. | | equals | Signal | Equality of stored signal values, including manual writes. Default is strict equality (===); false disables suppression. | | writePolicy | Signal | "native" (default) or "preserve". Controls manual writes versus in-flight derivations. |

For precise generic types, import AsyncEffectOptions, AsyncMemoOptions, AsyncSignalOptions, AsyncSignalSetter, AsyncSource, Resolved, and Equality from solid2-effector. Subpath imports (solid2-effector/effect, /memo, /signal) are also available.

Behavior and limitations

  • Each async source is tracked separately. The derivation waits until all current sources are resolved; stale Promise completions are ignored.
  • Equality compares resolved values, not requests. New source dependencies can still trigger network calls even when the result compares equal.
  • Source and result equality do not affect unrelated synchronous dependencies read by derive.
  • The primitives do not provide built-in request caching, cancellation, deduplication, or retries.
  • createAsyncSignal is experimental and aims for native-style setter precedence, not complete equivalence to Solid 2's scheduling and loading semantics.