Skip to content

Module interface

Home > @rimitive/core > Module

A module definition - the unit of composition in Rimitive.

Modules declare their dependencies and provide a create function that receives resolved dependencies and returns the implementation.

Signature:

export interface Module<TName extends string = string, TImpl = unknown, TDeps = unknown>

Property

Modifiers

Type

Description

dependencies

AnyModule[]

Modules this module depends on (resolved by compose)

name

TName

Unique name - becomes the property name on the composed context

status

typeof STATUS_MODULE

Status marker for runtime type discrimination

Method

Description

create(deps)

Create the implementation with resolved dependencies

destroy(ctx)?

(Optional) Optional: called when context is disposed

init(ctx)?

(Optional) Optional: called when module is added to context

instrument(impl, instrumentation, ctx)?

(Optional) Optional: wrap impl for debugging/profiling when instrumentation is enabled