Skip to content

Playground

An interactive, editable BlaC sandbox running entirely in your browser. No install needed — just edit the code and watch it update.

The starter demonstrates a Cubit with typed state, a useBloc hook consumer, and a render counter wired directly in the render body (not useEffect) so every real re-render is counted accurately.

FileRole
App.tsxRoot component; renders the Counter component and passes nothing — the Cubit is resolved automatically from the global registry.
counter.tsCounterCubit — start here. Add state fields, tweak actions, or model an explicit event log in state.
RenderCounter.tsxUtility component that counts renders in the render body. Carry this into any component to measure re-render isolation.
styles.cssPlain CSS — no framework. Edit freely.

Extend the Cubit — add a history: number[] field and record each value after every increment.

Per-consumer isolation — split the counter display into two sibling components: one reads state.count, the other reads state.step. Add render counters to both, then change the step. Only the step reader should re-render.

Async action — add an incrementAfterDelay method that calls setTimeout before invoking this.update(...). Watch the UI stay responsive while the delay runs.

Event log — add a CounterEvent union and an events: CounterEvent[] field. Have each action append an event before applying the state change, so you can inspect the history without introducing a separate dispatch API.