Clip
DSL function to place a prebuilt pattern on the timeline
Clip
Module: jindong-compose | Package: io.github.compose.jindong.dsl
Places a prebuilt HapticPattern on the timeline at the current position.
Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
pattern | HapticPattern | The prebuilt pattern to place on the timeline |
Description
Clip drops a self-contained pattern next to inline nodes. It is the bridge between a HapticPattern value, typically an algebra result built with buildHapticPattern, and the composable DSL. The clip's events are offset by the nodes that precede it, so it schedules relative to its position like any other node.
Freezing and re-firing
A clip captures its pattern at compile time. Because Jindong compiles content in a single pass with no recomposition (see The Reactive Contract), swapping the pattern in state alone does not update the clip. Thread the pattern through the trigger keys to make it live:
HapticPattern is a data class, so the key comparison is structural: an equal pattern does not re-fire, a different one does.
Do not add a Jindong(pattern, vararg keys) overload to skip the Clip call. Jindong(p) { ... } resolves to the existing vararg keys overload with p as a key, which compiles but plays the lambda instead of p. The Jindong(pattern) { Clip(pattern) } idiom is the supported way to embed a value.
Usage
Composing with the pattern algebra
Clips pair well with the pattern transforms, which return new HapticPattern values:
Reusing a pattern across screens
Notes
- The pattern is captured when the node is inserted, not on every frame
- Preceding
DelayandHapticnodes shift the clip's start time HapticPatternequality is structural, which drives key comparison- An empty pattern (
HapticPattern.Empty) places nothing