package com.example.myapplication.database

import android.content.Context
import com.example.myapplication.database.repository.CategoryRepository
import com.example.myapplication.database.repository.OfflineCategoryRepository
import com.example.myapplication.database.repository.OfflineProductRepository
import com.example.myapplication.database.repository.OfflineUserRepository
import com.example.myapplication.database.repository.ProductRepository
import com.example.myapplication.database.repository.UserRepository

interface AppContainer {
    val userRepository: UserRepository
    val productRepository: ProductRepository
    val categoryRepository: CategoryRepository
}
class AppDataContainer(private val context: Context) : AppContainer {
    override val userRepository: UserRepository by lazy {
        OfflineUserRepository(AppDb.getInstance(context).userDao())
    }
    override val productRepository: ProductRepository by lazy {
        OfflineProductRepository(AppDb.getInstance(context).productDao())
    }

    override val categoryRepository: CategoryRepository by lazy {
        OfflineCategoryRepository(AppDb.getInstance(context).categoryDao())
    }

    companion object {
        const val TIMEOUT = 5000L
    }
}