Skip to content
Proyectos

Acerca de

Zero-provider, type-safe state management — class-based BLoC pattern for React and Preact with automatic property tracking

Desarrollo web y de aplicaciones

Cómo se miden estas cifras

What you can do

  • Class-based state containers — Business logic lives in typed classes, not components
  • Automatic re-render optimization — Proxy-based tracking detects which properties you read and only re-renders when those change
  • Zero providers — No context wrappers. Import a class, call useBloc, done
  • Lifecycle management — Registry handles instance creation, sharing, ref counting, and disposal

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

BlaC

Type-safe, class-based state management for React with automatic re-render optimization.

Documentation · npm · GitHub

[!WARNING] BlaC v2 is in pre-release (beta). While in beta, breaking API changes may ship in patch releases without a major version bump. Pin an exact version and check the changelog before upgrading. Strict semver resumes once v2 is officially out of beta.

Features

  • Class-based state containers — Business logic lives in typed classes, not components
  • Automatic re-render optimization — Proxy-based tracking detects which properties you read and only re-renders when those change
  • Zero providers — No context wrappers. Import a class, call useBloc, done
  • Lifecycle management — Registry handles instance creation, sharing, ref counting, and disposal
  • Plugin system — DevTools, logging, and persistence (IndexedDB or Web Storage) out of the box
  • React bindings — useBloc subscribes via useSyncExternalStore and tracks reads through a proxy, re-rendering only for the paths a component actually reads
  • Framework-agnostic core — @blac/core has no React dependency; state can be read and observed through watch() outside of React

Quick Start

pnpm add @blac/core @blac/react
import { Cubit } from '@blac/core';
import { useBloc } from '@blac/react';

class CounterCubit extends Cubit<{ count: number }> {
  constructor() {
    super({ count: 0 });
  }
  increment = () => this.emit({ count: this.state.count + 1 });
}

function Counter() {
  const [state, counter] = useBloc(CounterCubit);
  return <button onClick={counter.increment}>{state.count}</button>;
}

Only state.count is tracked — the component won't re-render if other properties change.

Packages

Package Description
@blac/core State containers, registry, plugins, watch & tracking utilities
@blac/react React hook (useBloc) with proxy-based auto-tracking
@blac/async Resources and mutations kept in state, with tag invalidation
@blac/devtools-connect DevTools connection plugin (browser inspector)
@blac/devtools-ui Embeddable DevTools UI — overlay or Picture-in-Picture
@blac/logging-plugin Console logging with memory monitoring
@blac/plugin-persist IndexedDB and Web Storage persistence with hydration

Development

This is a pnpm workspace monorepo using Vite+ for builds.

pnpm install

pnpm dev                         # watch all packages
pnpm build                       # build all packages
pnpm --filter @blac/core test    # test a specific package
pnpm typecheck                   # type check all packages
pnpm lint                        # lint all packages

License

MIT

Explorar proyectos relacionados

Cargando…