What you'll learn
- How directives separate state transitions from side effects
- How to schedule delayed or recurring signals cleanly
- How to avoid runaway loops in time-based workflows
- How to reason about clock, retries, and cancellation
Prerequisites
- You understand action return tuples and signal routing
- You can reason about eventually delivered messages
- You are comfortable debugging asynchronous behavior
Lesson Breakdown
- Directive fundamentals: emit, schedule, and compose side effect instructions.
- Scheduling model: one-shot schedules and self-rescheduling loops.
- Loop controls: state flags and termination conditions.
- Failure handling: retry windows, jitter, and dead-letter strategies.
- Testing time: assert directives rather than sleeping in tests.
Hands-on Exercise
Extend a demand tracker with auto-decay:
- Toggle auto-decay with
listing.demand.auto_decay.toggle. - Emit
listing.demand.changed after each decay. - Schedule a future
listing.demand.tick while auto mode is enabled. - Disable auto mode and confirm no future tick is scheduled.
- Add tests asserting emitted directives and schedule payloads.
Validation Checklist
- [ ] Actions return directives instead of executing side effects directly.
- [ ] Recurring behavior is state-controlled, not unconditional.
- [ ] Tests assert directive content and timing intent.
- [ ] Loop stops correctly when guard state flips.
Next Module
Continue with LiveView + Jido Integration Patterns.