CachingCantEatRepository

Implementation of the CantEatRepository interface. It uses a local database and a remote API for managing CantEat data.

Constructors

Link copied to clipboard
constructor(cantEatDao: CantEatDao, cantEatApiService: CantEatApiService)

Functions

Link copied to clipboard
open suspend override fun deleteCantEat(cantEat: CantEat)

Deletes a CantEat item from the remote API and the local database.

Link copied to clipboard
open override fun getCantEats(): Flow<List<CantEat>>

Fetches all CantEat items from the local database. If the local database is empty, it refreshes the data from the remote API.

Link copied to clipboard
open suspend override fun insertCantEat(cantEat: CantEat)

Inserts a CantEat item into the local database.

Link copied to clipboard
open suspend override fun refresh()

Refreshes the local database with data fetched from the remote API.

Link copied to clipboard
open suspend override fun saveCantEat(cantEat: CantEat): CantEat

Saves a CantEat item to the remote API and the local database. If the item already exists in the remote API, it updates the item. Otherwise, it creates a new item.

Link copied to clipboard
open suspend override fun updateCantEat(cantEat: CantEat)

Updates a CantEat item in the remote API and the local database.