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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@appboypov/informers

v1.0.0

Published

Reactive state management for React with Informer class and useInformerListenable hook - Flutter ValueNotifier pattern

Downloads

444

Readme

@appboypov/informers

Reactive state management for React with a ValueNotifier-like pattern inspired by Flutter.

Installation

npm install @appboypov/informers

Features

  • Informer class - Shared reactive state that can be used across components
  • useInformerListenable hook - Subscribe to Informer changes with automatic re-renders
  • InformerListenableBuilder components - Declarative component-based subscriptions
  • React 18 concurrent mode support via useSyncExternalStore
  • Zero dependencies (peer dependency on React 18+)

Quick Start

Shared State with Informer Class

import { Informer, useInformerListenable } from '@appboypov/informers';

// Create shared state (outside component)
const counter = new Informer(0);

function CounterDisplay() {
  // Subscribe to changes
  const count = useInformerListenable(counter);
  return <p>Count: {count}</p>;
}

function CounterButtons() {
  return (
    <div>
      <button onClick={() => counter.update(counter.value + 1)}>+</button>
      <button onClick={() => counter.updateCurrent(n => n - 1)}>-</button>
    </div>
  );
}

Builder Components

import { Informer, InformerListenableBuilder } from '@appboypov/informers';

const user = new Informer({ name: 'John', age: 30 });

function UserCard() {
  return (
    <InformerListenableBuilder
      informer={user}
      builder={(userData) => (
        <div>
          <h2>{userData.name}</h2>
          <p>Age: {userData.age}</p>
        </div>
      )}
    />
  );
}

API

Informer<T>

A reactive state container that notifies listeners when its value changes.

const informer = new Informer(initialValue, options?);

Constructor Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | forceUpdate | boolean | false | Notify listeners even when value is same reference |

Properties

| Property | Type | Description | |----------|------|-------------| | value | T | Current value (direct access, no subscription) |

Methods

| Method | Description | |--------|-------------| | update(value, options?) | Update value. Options: { doNotifyListeners?: boolean } | | updateCurrent(updater, options?) | Update using function: (current) => newValue | | rebuild() | Force notify listeners without changing value | | dispose() | Clear all listeners |

Example

const counter = new Informer(0);

// Direct access (no subscription)
console.log(counter.value); // 0

// Update and notify
counter.update(5);

// Update with function
counter.updateCurrent(n => n + 1);

// Silent update (no re-render)
counter.update(10, { doNotifyListeners: false });

// Force rebuild
counter.rebuild();

// Cleanup
counter.dispose();

useInformerListenable<T>(informer: Informer<T>): T

React hook that subscribes to an Informer and returns its current value. Component re-renders when the Informer's value changes.

const counter = new Informer(0);

function Counter() {
  const count = useInformerListenable(counter);
  return <p>Count: {count}</p>;
}

InformerListenableBuilder<T>

Component that rebuilds when an Informer's value changes.

<InformerListenableBuilder
  informer={counter}
  builder={(value) => <p>Count: {value}</p>}
/>

InformerListenableBuilder2<T1, T2>

Component that rebuilds when either of two Informers change.

const firstName = new Informer('John');
const lastName = new Informer('Doe');

<InformerListenableBuilder2
  informer1={firstName}
  informer2={lastName}
  builder={(first, last) => <p>{first} {last}</p>}
/>

InformerListenableBuilder3<T1, T2, T3>

Component that rebuilds when any of three Informers change.

<InformerListenableBuilder3
  informer1={firstName}
  informer2={lastName}
  informer3={age}
  builder={(first, last, userAge) => (
    <p>{first} {last}, {userAge} years old</p>
  )}
/>

Patterns

Global State

// stores/counter.ts
export const counterStore = new Informer(0);

// components/Counter.tsx
import { counterStore } from '../stores/counter';

function Counter() {
  const count = useInformerListenable(counterStore);
  return <p>{count}</p>;
}

Service with Reactive State

class UserService {
  readonly currentUser = new Informer<User | null>(null);
  readonly isLoading = new Informer(false);

  async login(email: string, password: string) {
    this.isLoading.update(true);
    try {
      const user = await api.login(email, password);
      this.currentUser.update(user);
    } finally {
      this.isLoading.update(false);
    }
  }
}

// In component
function UserStatus() {
  const user = useInformerListenable(userService.currentUser);
  const loading = useInformerListenable(userService.isLoading);

  if (loading) return <p>Loading...</p>;
  return <p>Welcome, {user?.name}</p>;
}

License

MIT