Quick Start
Build your first haptic pattern with Jindong in minutes
Quick Start
Let's build your first haptic feedback pattern with Jindong.
This guide covers the Compose API (jindong-compose module). For non-Compose usage, see Core API Guide.
Minimal Example
That's it! Every time you tap the button, a 100ms haptic pulse fires.
Understanding the Basics
JindongProvider
Provides the haptic execution context:
Jindong
The main composable for defining haptic patterns:
- Works like
LaunchedEffect - Executes when any key changes
- Content block defines the pattern
Haptic
Creates a vibration:
Building Patterns
Sequential Events
Events execute one after another:
Adding Delays
Use Delay for pauses between events:
Adjusting Intensity
Control vibration strength:
Repetition
Repeat patterns with Repeat:
Practical Examples
Screen Entry Feedback
Use Unit as key to trigger haptic immediately when entering a screen:
Button Tap Feedback
Success Notification
Error Alert
Fade Out Effect
Heartbeat Pattern
Common Patterns
| Pattern | Key | Code |
|---|---|---|
| On screen enter | Jindong(Unit) | Haptic(100.ms) |
| Single tap | Jindong(count) | Haptic(50.ms) |
| Double tap | Jindong(count) | Repeat(2) { Haptic(40.ms); Delay(40.ms) } |
| Long press | Jindong(count) | Haptic(200.ms, HapticIntensity.MEDIUM) |
| Success | Jindong(success) | Haptic(50.ms); Delay(50.ms); Haptic(100.ms) |
| Error | Jindong(error) | Repeat(3) { Haptic(80.ms); Delay(50.ms) } |
Tips
Key Management
Choose keys carefully:
Reactive Patterns
When a key changes, the content block is recompiled with the current state, so a value the block captures must also be one of the keys for the pattern to reflect it:
If a captured value is not in the keys, the pattern keeps the value from the last key change instead of updating. The Reactive Contract covers when values are read and when playback fires.
Next Steps
- Jindong API - Deep dive into the main API
- Composable DSL - All DSL primitives
- HapticIntensity - Intensity options