Skip to content
Projetos

Sobre

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

Desenvolvimento web e de aplicativos

Como estes números são medidos

O que você pode fazer

  • 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

Crescimento medido de estrelas

em 24 h
0
em 7 dias
0
em 15 dias
0
em 1 mês
Coletando histórico

Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.

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

Explore projetos relacionados

Carregando…