CachingLikeRepository

class CachingLikeRepository(likeDao: LikeDao, likeApiService: LikeApiService) : LikeRepository

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

Constructors

Link copied to clipboard
constructor(likeDao: LikeDao, likeApiService: LikeApiService)

Functions

Link copied to clipboard
open suspend override fun deleteLike(like: Like)

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

Link copied to clipboard
open override fun getLikes(): Flow<List<Like>>

Fetches all Like 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 insertLike(like: Like)

Inserts a Like 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 saveLike(like: Like): Like

Saves a Like 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 updateLike(like: Like)

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