Skip to content

API reference > @kontsedal/olas-core > CollectionFactoryOptions

CollectionFactoryOptions type ​

Heterogeneous form of ctx.collection: a single factory decides per-item which controller + props to construct. When a key's factory result picks a *different* controller than last time, the existing child is disposed and the new one constructed (type-discriminant rebuild).

R is the factory's *return type* (typically inferred as the union of the branches' { controller, props } shapes). Api is then projected out as the union of every branch's controller Api via CollectionFactoryApi<R> — unlike a single Api generic, the union doesn't collapse to the first branch.

Signature:

typescript
type CollectionFactoryOptions<Item, K, R, TDeps = AmbientDeps> = {
  readonly source: ReadSignal<readonly Item[]>;
  readonly keyOf: (item: Item) => K;
  readonly controller?: never;
  readonly propsOf?: never;
  readonly factory: (item: Item) => R;
  readonly deps?: Partial<TDeps>;
};

References: AmbientDeps, ReadSignal

Released under the MIT License.