Logo Mibo

AdaptiveInit Module

Helpers for building an AdaptiveInit.

These keep the Disposables list and the default subscription projection hidden: AdaptiveInit.ofFrameBuilder defaults them (empty subscriptions, no disposables), and AdaptiveInit.withSubscriptions / AdaptiveInit.withDisposables / AdaptiveInit.withDisposable replace or append to them. Callers never write Disposables = [] by hand.

Functions and values

Function or value Description

ofFrameBuilder frameBuilder

Full Usage: ofFrameBuilder frameBuilder

Parameters:
    frameBuilder : unit -> 'Frame - Forces the frame's output projections and packs them into 'Frame.

Returns: AdaptiveInit<'Frame>
Modifiers: inline
Type parameters: 'Frame

Creates an init from a frame builder with no subscriptions and no disposables.

frameBuilder : unit -> 'Frame

Forces the frame's output projections and packs them into 'Frame.

Returns: AdaptiveInit<'Frame>

withDisposable disposable init

Full Usage: withDisposable disposable init

Parameters:
Returns: AdaptiveInit<'Frame>
Modifiers: inline
Type parameters: 'Frame

Adds a single disposable to the init. The disposable is released when the runner is disposed.

disposable : IDisposable
init : AdaptiveInit<'Frame>
Returns: AdaptiveInit<'Frame>

withDisposables disposables init

Full Usage: withDisposables disposables init

Parameters:
Returns: AdaptiveInit<'Frame>
Modifiers: inline
Type parameters: 'Frame

Appends a list of disposables to the init. The disposables are released when the runner is disposed.

disposables : IDisposable list
init : AdaptiveInit<'Frame>
Returns: AdaptiveInit<'Frame>

withSubscriptions subscribe init

Full Usage: withSubscriptions subscribe init

Parameters:
Returns: AdaptiveInit<'Frame>
Modifiers: inline
Type parameters: 'Frame

Sets the subscription projection. The runner reads the map once per step (skipping the read when nothing changed), compares it by SubId against its attached table, and starts new, keeps matching, and stops vanished subscriptions. The adaptive counterpart of Program.withSubscription.

The projection must return a stable map: build it once and return the same instance. The runner checks the map's version every step and skips the diff when nothing changed. If you need subscriptions that change with game state, use AMap.custom and describe the changes yourself — do not build a fresh map from adaptive values (for example AMap.ofAVal) inside the projection, that would create a new graph every step. Subscription work feeds the step cycle: it runs at the next step's boundary, before Update. Do not modify game state from it beyond what the step cycle expects.

subscribe : AdaptiveFrameContext -> amap<SubId, AdaptiveSub>

Builds the subscription map from the context.

init : AdaptiveInit<'Frame>

The init to configure.

Returns: AdaptiveInit<'Frame>

Type something to start searching.