Skip to content
qubeejs/angular
API/createQubeeInstance

createQubeeInstance

function@qubeejs/angularsrc/lib/create-qubee-instance.ts

Create an isolated query builder, paginator and store, wired together

provideQubeeInstance() isolates state per component. This factory does the same for code that has no component injector to hang providers on — typically a root-scoped feature service that wants private query state instead of sharing the app-wide QubeeQueryBuilder with every other service. Two root services that each call it never see each other’s filters or pages.

The three objects are created in a child injector of injector, so the driver, strategies and options configured by provideQubee() are inherited; only the state is new. Nothing needs tearing down: the child injector is referenced only by the objects it created and is collected with them.

createQubeeInstance(injector?: Injector): QubeeInstance
Parameter Type Description
injector? Injector The injector to inherit the driver wiring from. Defaults to the current injection context, so a field initialiser or constructor of an injectable can omit it; pass one explicitly when calling from elsewhere.

Returns — The builder, paginator and the store they share

Throws — If called outside an injection context without an injector.

@Injectable({ providedIn: 'root' })
export class UserApi {
private readonly _qubee = createQubeeInstance();
readonly users = httpResource<RawResponse>(() => this._qubee.builder.uri());
list(): void {
this._qubee.builder.setResource('users').setLimit(25);
}
}