Core API
Using Jindong without Compose Runtime
Core API
Module: jindong-core | Package: io.github.compose.jindong.core
The Core API allows you to use Jindong haptic patterns without Compose Runtime dependency. This is useful for:
- Non-Compose Kotlin Multiplatform projects
- ViewModel or Repository layer haptic triggers
- Background services or workers
Installation
Building Patterns
Use buildHapticPattern to create haptic patterns:
Executing Patterns
Suspend Function (Recommended)
Use play() to execute and wait for completion:
Fire-and-Forget
Use playAsync() when you don't need to wait:
Inline Execution
Use playHaptic for one-off patterns:
HapticManager
HapticManager is a singleton that manages haptic execution:
Platform Initialization
Android
Automatic initialization via JindongInitializer ContentProvider. No manual setup needed.
For multi-process apps, call manually:
iOS
No initialization required.
DSL Reference
haptic
Creates a vibration event:
delay
Adds a pause between events:
repeat
Repeats a block N times:
repeatWithIndex
Repeats with index access for dynamic patterns:
sequence
Groups elements (optional, for organization):
include
Includes an existing pattern:
Examples
ViewModel Usage
Repository Pattern
Comparison with Compose API
| Feature | Core API | Compose API |
|---|---|---|
| Compose Runtime | Not required | Required |
| Trigger mechanism | Manual (play()) | Key-based (like LaunchedEffect) |
| Pattern definition | buildHapticPattern {} | Jindong {} composable |
| DSL style | Regular functions | @Composable functions |
| Use case | ViewModels, services | UI components |
See Also
- Getting Started - Installation guide
- HapticIntensity - Intensity levels
- Compose API - Compose-based API