jerboa icon indicating copy to clipboard operation
jerboa copied to clipboard

Introduce dependency injection

Open oscarnylander opened this issue 1 year ago • 4 comments

Dependency Injection can:

  • Help reduce the amount of reliance on singletons
  • Reduce the amount of glue code necessary
  • Improve the testability of the codebase

I recommend hilt, as it builds on Dagger but reduces the undesirable amount of complexity present in setting up Dagger yourself.

oscarnylander avatar Jun 03 '23 10:06 oscarnylander

@dessalines Since there's some significant work involved in refactoring the app to use Hilt, let me know if you're interested in getting this in. If you do, I can probably get it done, but I'd like to avoid the effort if not.

oscarnylander avatar Jun 04 '23 18:06 oscarnylander

Yeah don't start work on this yet... I'm not a huge fan of these annotation-based, dependency injection frameworks, unless room absolutely can't work without it. I've always found them to be less code-traceable, and essentially hacks to make the code look just a little nicer.

It would only be useful for the HTTP and DB singletons, and since most of that work is done already, doesn't seem worth the effort.

dessalines avatar Jun 04 '23 19:06 dessalines

Alright.

I think one of the more interesting things that Hilt could provide would be Navigation Destination-scoped ViewModels, which (without looking too closely) would probably solve #402.

oscarnylander avatar Jun 04 '23 19:06 oscarnylander

That one hopefully should be solved in the autogen_types branch. I use a better HTTP result sealed class(with empty, loading, success, and failed results), which should handle loading better.

dessalines avatar Jun 04 '23 20:06 dessalines

Stale issue.

dessalines avatar Feb 10 '24 21:02 dessalines