[β οΈ JOURNEY] Building MP3 AI Manager for Music Hoarders (Day 20)
Day 20
Hours worked/Total: 4.5/41
Day Recap
Focused on learning how to share data between ViewModels. After experimenting with different approaches like dependency injection, singletons, and messaging, successfully implemented Prism for Avalonia. While initially stuck with dependency injection issues, revising shared services and following Prism examples resolved the problems, enabling event driven messaging.
What I Did
- Reviewed various ViewModel data sharing approaches:
- Dependency injection: Simplifies passing shared services.
- Singletons: For global, app-wide shared states.
- Messaging: Event-driven communication between ViewModels.
- Chose Prism for its event aggregation and IoC (Inversion of Control) features.
- Revised shared services by integrating Prism’s EventAggregator to propagate changes to the UI
- Learned IoC and containerization (as I understand it):
- Containers manage class instances, their lifetimes, and injections automatically.
- Added DryIoc containers but faced issues:
- AXAML views couldn’t see ViewModels, breaking bindings and messaging.
- DryIoc setup became overly complex for my needs.
- Resolved issues by taking 2 steps back:
- Followed Prism’s Avalonia example project, step by step.
- Ditched DryIoc and used Prism’s built-in IoC framework instead.
- Magically, everything worked. Messaging now propagates changes between ViewModels.
Remarks
Understanding IoC and dependency injection has been a game changer, but it was a steep learning curve. Prism simplifies a lot of these concepts
Next Goals
Start working on file explorer.