code-with-the-italians / bundel

A digital wellbeing Android app that helps minimise distractions when you don't want them. Watch us live code it at https://cwti.link/twitch or catch up on YouTube at https://cwti.link/yt. Merch available at https://cwti.link/spaccio.
https://codewiththeitalians.it
Apache License 2.0
288 stars 26 forks source link

Optimize DatabaseModule DI setup #16

Closed ZianeA closed 3 years ago

ZianeA commented 3 years ago

I annotated the provideDatabase method with @Singleton annotation to avoid creating a new database instance for every injection. I also marked the DataRepository with @Singleton for similar reasons. Although DatabaseModule is installed in a singleton component, you still have to scope its bindings. See the following for more info: https://dagger.dev/hilt/components

I replaced the provide method with constructor injection to bind the DiskImagesStorage. However, one thing to note is that the ImagesStorage from DI is never used.

rock3r commented 3 years ago

Thanks for the PR @ZianeA! And congrats for opening our first PR on the project ✨ We'll review it asap

rock3r commented 3 years ago

However, one thing to note is that the ImagesStorage from DI is never used.

That's true — we plan to eventually use it, but we need to keep in mind it's not used yet :) Maybe we can get rid of it in the future, instead; let's see.