Skip to main content
The Voice Memos example demonstrates how to build a feature that interacts with device capabilities like the microphone and audio system. It showcases permission handling, audio recording and playback, and complex async effects.

Overview

This example shows how to:
  • Request and handle permissions
  • Record audio with real-time feedback
  • Play audio with progress tracking
  • Model complex state with enums
  • Create custom dependency clients
  • Coordinate multiple async effects

Implementation

Key Concepts

Permission Handling

Model permission state explicitly:
Request permission when needed:

State Machines with Enums

Model playback state as an enum:
This ensures:
  • Progress only exists when playing
  • Invalid states are impossible
  • Transitions are explicit

Audio Playback

Manage playback with coordinated effects:

Custom Dependencies

Define audio client interfaces:

Coordinating Multiple Memos

Stop other memos when one starts playing:

Presentation Logic

Use @Presents for modals and alerts:
Integrate with reducers:

Testing

Source Code

View the complete example in the TCA repository:

Next Steps