src: make LobstersRepository a singleton

Earlier both LobstersViewModel and LobstersPagingSource were getting a different instance of LobstersRepository.
This lead to cache issues where LobstersPagingSource filled the cache but it was not available to the LobstersViewModel.

Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
This commit is contained in:
Aditya Wasan 2021-02-05 15:00:23 +05:30
parent 9ce33bba75
commit 0fcf584b01
No known key found for this signature in database
GPG key ID: 6D6DF3BF15DE79B5
4 changed files with 32 additions and 8 deletions

View file

@ -5,7 +5,7 @@ import dagger.Lazy
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.components.SingletonComponent
import dev.msfjarvis.lobsters.data.api.LobstersApi
import okhttp3.OkHttpClient
import retrofit2.Retrofit
@ -13,7 +13,7 @@ import retrofit2.converter.moshi.MoshiConverterFactory
import retrofit2.create
@Module
@InstallIn(ViewModelComponent::class)
@InstallIn(SingletonComponent::class)
object ApiModule {
@Provides