Viet Phan X

[⚠️ JOURNEY] Building MP3 AI Manager for Music Hoarders (Day 20)

Author AvatarViet Phan
1
Jan 12, 2025
2 min read

Day 20

Hours worked/Total: 4.5/41

Avaloniastate

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.

πŸ‘¨β€πŸ’» Software DevelopmentπŸš€ Journey

Got an Idea?

Let's Build It!

I can bring your ideas to life - FREE of charge

Book a free consultation and let’s identify opportunities to turn your vision into a successful business

15 min call

Get idea feedback

from 17+ consultations
?
Usually responds within 24h

If You Like what I do
You can buy me a coffee πŸ‘‡
Send β˜• via PayPalSend β˜• with Bitcoin

πŸ€™ Let's connect

Made by Viet Phan Β© 2018-2025Privacy Policy