App Failures by Koin. Story 4 — Does It Worth Sharing a ViewModel

Viktoriia.io
6 min readDec 22, 2020

This story is here to define some pieces of advice for sharing ViewModel between host Activity & Fragments, or simply between Fragments.

Photo by Bianka Ackermann on Unsplash

The Roadmap

As a true lover of Koin DI framework, in this series of stories, I’d like to share some of the true app failures my team gained when we started using Koin. (Most of them were found in production, unfortunately…)

Story 1 — Be Careful With Singletons

Story 2 — Unreliable Dynamic Loading

Story 3 — Issue With sharedViewModel()

Story 4 — Does It Worth Sharing a ViewModel? (we are here)

… to be continued…

If you’re not yet familiar with sharing data with Koin, please first read Story 3 from this series. The current story is supposed to be a continuation of Story 3, more providing you with some tips on when to share and what worth to be shared.

Common Mistakes & Tips to Improve

One of the trends for Android development of the last years is designing application architecture as a single host Activity with some Fragments, which navigation is handled by Navigation component. From my experience, for most average applications single activity…

--

--