Challenges
Challenges are the core of PrismGamification. Define them as a Swift enum conforming toPrismChallenge, and the manager handles persistence, progress tracking, and events.
The PrismChallenge Protocol
Protocol Definition
Challenge Types
Complete Example
Registration
Register all cases of your challenge enum. Idempotent — safe to call on every app launch:Register Challenges
Tracking Progress
Counter Challenges
Increment
currentValue >= goal. Values clamp to goal — never overshoot.
Milestone Challenges
Complete
Querying Progress
Queries
PrismChallengeSnapshot
All queries returnPrismChallengeSnapshot — a Sendable value type:
Resetting
Reset
Events
Subscribe to challenge events viaAsyncStream:
Event Stream
Error Handling
All errors are
PrismGamificationError — equatable and localized.