Showcase
Each demo below runs entirely in your browser via
Sandpack. Sandpack installs the published
@blac/core and @blac/react packages from its CDN, so you’re running the real
API — not a mock or workspace build.
Every embed is fully editable. Hit View code, change a file, and watch the preview hot-reload. Click Open in CodeSandbox (top-right of the editor) to fork the sandbox and keep experimenting.
Counter
Section titled “Counter”The minimum viable BlaC app. One CounterCubit holds { count, lastAction }.
The component calls cubit methods — no action objects, no reducers, no dispatch.
Cubit— subclass with a typed initial statepatch()— partial-merge update;emit()for a full replaceuseBloc()— returns[state, cubit](no provider needed)
Todo list
Section titled “Todo list”Multiple components consume the same TodoCubit without any extra wiring —
no context, no prop-drilling. Derived getters (filteredItems, activeCount)
live on the cubit and recompute whenever state changes.
- Reactive list state — add, toggle, remove, filter
- Derived getters on the Cubit class
- Multiple unrelated components, all reading the same singleton
Registration form
Section titled “Registration form”FormCubit tracks every field’s value and touched flag, plus computed
errors, isValid, and progress. Validation logic stays in the cubit — the
components are pure view.
- Per-field touched state — errors surface only after blur
- Derived
errorsgetter returns only fields that fail - Progress bar driven by a computed percentage, no local state
Analytics dashboard
Section titled “Analytics dashboard”Two independent Cubits — StatsCubit (counters + live simulation) and
ActivityCubit (event log) — coexist without a provider. A useEffect in
App writes to the activity log whenever stats refresh, showing cross-cubit
coordination via React effects instead of this.depend().
- Two Cubits used in the same tree, no shared provider
- Live simulation with
setIntervalmanaged inside the cubit - Cross-cubit coordination via React effects
What to try
Section titled “What to try”Once a demo loads, hit View code and try these edits to explore the API:
- Counter — add a
doublemethod toCounterCubitthat callsthis.patch({ count: this.state.count * 2 }). - Todo — add a
prioritize(id)method and apriorityfield to theTodointerface; sortfilteredItemsby priority. - Form — add a fourth field (e.g.
username) and a uniqueness rule toerrors. - Dashboard — wire
StatsCubittoActivityCubitusingthis.depend()insideStatsCubit.tick()so the log updates without a React effect.