mrsegev / MovieNight

MovieNight is a sample Android application that uses the clean architecture approach and is written in Kotlin.
772 stars 144 forks source link

Room cache bug accessing on main thread when switching caching mechanism #4

Closed DaanGeurts closed 6 years ago

DaanGeurts commented 6 years ago

First of all, I wanted to say that your tutorial / blog post was a great and inspiring to me to create more maintainable Android code. So a big thank you!

But you say in your blogpost that you can easily switch between caching mechanisms but when I switch the cache for the movierepository to DI.favoritesCache (Room instead of memory) the app won't launch because of accessing the DB on the mainthread. This happens I think of accessing the cache directly in the MovieRepositoryImpl file with if (!cache.isEmpty())

Do you have any thoughts on this? And again, thank you for this inspiring post and repo!!

mrsegev commented 6 years ago

Nice cache! That was indeed a bug. Should be fixed now by: https://github.com/mrsegev/MovieNight/commit/fdd1b28b7e21b94c50e2cd01adf7fb8dc4c8746c

DaanGeurts commented 6 years ago

Can you explain me why you are talking to the cache implementation directly and not asking the memoryDataStore for movies and check for and empty response?