Advanced / Composition · guide
Imperative APIs, SceneBuilder.render, batch & chain
Current Apexify.js 6.0.0 documentation for Imperative APIs, SceneBuilder.render, batch & chain.
Scene entry points resolve $ references by default. Imperative helpers and SceneBuilder.render() default to literal values unless you explicitly opt in.
Resolution matrix
| Entry point | Default | Control |
|---|---|---|
renderScene, scene step of renderSceneToGIF, scene step of renderSceneToVideoFrames | Resolve $ refs | { resolveAssetRefs: false } to skip |
SceneBuilder.render from painter.createScene() | No resolution | { resolveAssetRefs: true } |
createCanvas, createImage, createText, measureText, chart helpers, createGIF, animate, createVideo | No resolution | Supported trailing PainterAssetRefsOptions with { resolveAssetRefs: true } |
batch, chain | No resolution | { resolveAssetRefs?: boolean; resolve?: AssetResolveFn } |
| Templates | Resolve inside template pipeline | Custom resolver may be supplied when creating the template |
Templates call the final renderScene with asset resolution disabled because their scene snapshot is already resolved.
Imperative canvas
Without the trailing opt-in, $app.canvas remains a literal string.
SceneBuilder
Builders created through ApexPainter.createScene() carry the painter's asset resolver. Direct low-level SceneBuilder construction without a resolver cannot resolve $ references.
batch
chain uses the same BatchChainAssetOpts. When resolution is enabled, Apexify walks batch config objects or non-current chain arguments using the shared asset-reference engine.
A custom resolve function uses the public AssetResolveFn contract and may return supported AssetValue data, including scalars, Buffers, arrays, and plain records. The target field still needs to accept the resolved value; embedded-in-string references remain scalar-only.
prepareForRender
Use prepareForRender() when you want one resolved snapshot reused by several imperative calls.
The input composition is not mutated. JSON-like records/arrays are copied, Buffers are copied, $$ escapes literal dollar signs, and cyclic composition graphs are rejected rather than recursing indefinitely.
Whole-field vs embedded references
Whole-field references preserve their native value. Embedded references are converted to text and therefore must resolve to string/number/boolean scalars.
Back to Composition hub.