mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
chore: Flow version of firstOrNull
This commit is contained in:
parent
19ea7cbebd
commit
106737371f
6 changed files with 47 additions and 0 deletions
|
@ -30,6 +30,9 @@ class MangaRepositoryImpl(private val handler: DatabaseHandler) : MangaRepositor
|
|||
override fun getMangaListAsFlow(): Flow<List<Manga>> =
|
||||
handler.subscribeToList { mangasQueries.findAll(Manga::mapper) }
|
||||
|
||||
override fun getMangaByUrlAndSourceAsFlow(url: String, source: Long): Flow<Manga?> =
|
||||
handler.subscribeToFirstOrNull { mangasQueries.findByUrlAndSource(url, source, Manga::mapper) }
|
||||
|
||||
override suspend fun getLibraryManga(): List<LibraryManga> =
|
||||
handler.awaitList { library_viewQueries.findAll(LibraryManga::mapper) }
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import yokai.domain.manga.models.MangaUpdate
|
|||
interface MangaRepository {
|
||||
suspend fun getMangaList(): List<Manga>
|
||||
suspend fun getMangaByUrlAndSource(url: String, source: Long): Manga?
|
||||
fun getMangaByUrlAndSourceAsFlow(url: String, source: Long): Flow<Manga?>
|
||||
suspend fun getMangaById(id: Long): Manga?
|
||||
suspend fun getFavorites(): List<Manga>
|
||||
suspend fun getReadNotFavorites(): List<Manga>
|
||||
|
|
|
@ -7,6 +7,7 @@ class GetManga (
|
|||
) {
|
||||
suspend fun awaitAll() = mangaRepository.getMangaList()
|
||||
fun subscribeAll() = mangaRepository.getMangaListAsFlow()
|
||||
fun subscribeByUrlAndSource(url: String, source: Long) = mangaRepository.getMangaByUrlAndSourceAsFlow(url, source)
|
||||
|
||||
suspend fun awaitByUrlAndSource(url: String, source: Long) = mangaRepository.getMangaByUrlAndSource(url, source)
|
||||
suspend fun awaitById(id: Long) = mangaRepository.getMangaById(id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue