Coverage Summary for Class: LabelPagerExt (com.stslex93.notes.core.label.repository)
Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
LabelPagerExt |
0%
(0/1)
|
|
0%
(0/7)
|
0%
(0/30)
|
LabelPagerExt$getPagingLabels$$inlined$map$1 |
0%
(0/2)
|
|
LabelPagerExt$getPagingLabels$$inlined$map$1$1 |
|
LabelPagerExt$getPagingLabels$$inlined$map$1$2 |
0%
(0/1)
|
|
LabelPagerExt$getPagingLabels$$inlined$map$1$2$1 |
|
LabelPagerExt$getPagingLabels$1 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/4)
|
LabelPagerExt$getPagingLabels$2$1 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/8)
|
Total |
0%
(0/6)
|
|
0%
(0/9)
|
0%
(0/42)
|
package com.stslex93.notes.core.label.repository
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import androidx.paging.PagingSource
import androidx.paging.map
import com.stslex93.notes.core.database.label.LabelEntity
import com.stslex93.notes.core.label.model.LabelDataMapper.toData
import com.stslex93.notes.core.label.model.LabelDataModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
object LabelPagerExt {
const val PAGE_SIZE = 30
const val IS_PLACEHOLDER_ENABLE = false
inline fun getPagingLabels(
crossinline action: () -> PagingSource<Int, LabelEntity>,
): Flow<PagingData<LabelDataModel>> = Pager(
PagingConfig(
pageSize = PAGE_SIZE,
enablePlaceholders = IS_PLACEHOLDER_ENABLE
)
) {
action()
}
.flow
.map { pagingData ->
pagingData.map { it.toData() }
}
.flowOn(Dispatchers.IO)
}