Skip to main content

Setup

Blac <3 React​

Blac has a minimal boilerplate to get you started, all you need is one file to initialize and configure Blac:

state.ts
import { BlacReact } from "blac";

const state = new BlacReact([]);
export const { useBloc } = state;

As you can see, only three lines are needed to initialize Blac and get access to the useBloc hook.

Import this initialization file in your app, make sure this runs before accessing the state in your app, for react it is recommended to do this in index.tsx:

index.tsx
import './state';

Thats it, you you just need to create a Bloc or a Cubit and use it in your app.

Configuring Blac​

The Blac class takes two arguments, the first is an array of Blocs, the second is the ConsumerOptions.