Skip to content

BlaCBusiness Logic Components

Type-safe state management for React with automatic re-render optimization

Quick Example

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

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

// 2. Use it in any component — state is shared automatically
function Counter() {
  const [state, counter] = useBloc(CounterCubit);
  return <button onClick={counter.increment}>{state.count}</button>;
}

Installation

bash
pnpm add @blac/core @blac/react
bash
npm install @blac/core @blac/react
bash
yarn add @blac/core @blac/react

Released under the MIT License.