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

@efesto-cloud/react-observable

v0.0.2

Published

React Observable type for efesto-cloud

Readme

@efesto-cloud/react-observable

React hooks that subscribe to an Observable and re-render on change.

Use these when a React component needs to read the current value of an Observable and update when it changes. For raw subscriptions outside React, use @efesto-cloud/observable directly.

Installation

pnpm add @efesto-cloud/react-observable @efesto-cloud/observable react

Quick Start

import { Observable } from "@efesto-cloud/observable";
import useObservable from "@efesto-cloud/react-observable";

const count = new Observable(0);

function Counter() {
    const value = useObservable(count);
    return <button onClick={() => count.set(value + 1)}>{value}</button>;
}

API

useObservable<T>(observable)

Generic hook — returns the current value of any IObservable<T> and re-renders on change.

function useObservable<T>(observable: IObservable<T>): T;
const theme = new Observable<"light" | "dark">("light");

function ThemeBadge() {
    const current = useObservable(theme);
    return <span>{current}</span>;
}

useBooleanObservable(observable)

Specialization for IObservable<boolean>. Same contract as useObservable, but typed to boolean.

function useBooleanObservable(observable: IObservable<boolean>): boolean;

useStringObservable(observable, onChange?)

Binds an IObservable<string> to a text input. Returns a [value, handleChange] tuple wired for <input onChange={...} />.

function useStringObservable(
    observable: IObservable<string>,
    onChange?: (value: string) => void,
): readonly [string, (e: React.ChangeEvent<HTMLInputElement>) => void];
const name = new Observable("");

function NameField() {
    const [value, onChange] = useStringObservable(name, (v) => name.set(v));
    return <input value={value} onChange={onChange} />;
}

useIntegerObservable(observable, onChange?)

Binds an IObservable<number> to a text input, keeping the raw string locally so the user can type intermediate states (empty, -, etc.). onChange fires only when the input parses to a valid integer.

function useIntegerObservable(
    observable: IObservable<number>,
    onChange?: (value: number) => void,
): readonly [string, (e: React.ChangeEvent<HTMLInputElement>) => void];
const age = new Observable(0);

function AgeField() {
    const [value, onChange] = useIntegerObservable(age, (v) => age.set(v));
    return <input value={value} onChange={onChange} />;
}

Rules

  • The hooks subscribe on mount and unsubscribe on unmount — don't call observable.subscribe yourself in the same component.
  • Swapping the observable identity between renders resyncs to the new observable's current value.
  • useStringObservable / useIntegerObservable do not call set on the observable themselves — pass an onChange that calls observable.set if that's what you want. This keeps the hook usable with read-only or derived observables.
  • useIntegerObservable returns the raw input string, not a number. It only invokes onChange when the string parses to a valid integer.

Related