MindboxEmbeddedBlock

fun MindboxEmbeddedBlock(placeSystemName: String, modifier: Modifier = Modifier, timeoutMs: Long? = null, loadingStrategy: MindboxEmbeddedBlockLoadingStrategy = MindboxEmbeddedBlockLoadingStrategy.AUTOMATIC, animatesReveal: Boolean = true, onLoad: () -> Unit = {}, onEmpty: () -> Unit = {}, onFail: (MindboxEmbeddedBlockFailReason) -> Unit = {}, placeholder: @Composable () -> Unit? = null, error: @Composable () -> Unit? = null)

An embedded Mindbox block as a composable.

The caller names a place and gives the block an explicit height; the SDK decides what the place shows. The block takes the whole available width, and zero height when there is nothing to show. The behavior is that of MindboxEmbeddedBlockView. Keep the block in the composition rather than removing it in onEmpty: a collapsed block still shows content the place gets later.

MindboxEmbeddedBlock(
placeSystemName = "main-screen-top",
modifier = Modifier.height(120.dp),
)

Parameters

placeSystemName

The place the block fills. Whitespace around it is trimmed, letter case is ignored. A new name builds a new block.

timeoutMs

How long the block waits for the SDK's answer before failing with MindboxEmbeddedBlockFailReason.NETWORK_ERROR. null takes the mindbox_embedded_block_timeout_ms integer resource, 30 s by default. Counted while the screen with the block is shown. Fixed when the block is created.

loadingStrategy

What the block shows until the SDK answers. MindboxEmbeddedBlockLoadingStrategy.AUTOMATIC by default. Fixed when the block is created.

animatesReveal

Whether the content is revealed with an animation. true by default. Fixed when the block is created.

onLoad

The content is shown. Main thread.

onEmpty

The place has nothing to show; the block collapsed. Main thread.

onFail

The block could not get or show its content; the block collapsed or shows error. The reason is one of the MindboxEmbeddedBlockFailReason constants. Main thread.

placeholder

Replaces the SDK's shimmer while the content is loading. Fills the block.

error

Shown instead of collapsing the block when it fails. Failures only. Set it before the block fails: a slot set after the block has collapsed, for example in onFail, does not expand it. A block that waits hidden shows no error view. Fills the block.