Skip to content

API reference > @kontsedal/olas-core > createRoot

createRoot() function ​

Construct a root controller. Root factories take no props — startup config goes in deps.

deps is checked against AmbientDeps: in an app that augments it withapi: ApiClient, a root whose deps has no api does not compile. Extra members are allowed. createTestController does not check, so a test can pass only the fakes the controller under test reads.

Signature:

typescript
export declare function createRoot<Api, TDeps extends AmbientDeps = AmbientDeps>(def: ControllerDef<void, Api>, options: RootOptions<TDeps>): Root<Api>;

Parameters ​

Parameter

Type

Description

def

ControllerDef<void, Api>

options

RootOptions<TDeps>

Returns:

Root<Api>

Example ​

ts
const root = createRoot(counter, { deps, queries: queryEngine() })
root.api.increment()
root.dispose()

Released under the MIT License.