Skip to content

Commit

Permalink
Remove default params to flow extensions
Browse files Browse the repository at this point in the history
Would rather be verbose and safe than introduce the default dispatcher unknowingly in situations where it would cause issues
  • Loading branch information
Alec Strong committed Sep 7, 2022
1 parent eae3c34 commit 7aee4c6
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -58,7 +58,7 @@ fun <T : Any> Query<T>.asFlow(): Flow<Query<T>> = flow {

@JvmOverloads
fun <T : Any> Flow<Query<T>>.mapToOne(
context: CoroutineContext = Dispatchers.Default,
context: CoroutineContext,
): Flow<T> = map {
withContext(context) {
it.awaitAsOne()
Expand All @@ -68,7 +68,7 @@ fun <T : Any> Flow<Query<T>>.mapToOne(
@JvmOverloads
fun <T : Any> Flow<Query<T>>.mapToOneOrDefault(
defaultValue: T,
context: CoroutineContext = Dispatchers.Default,
context: CoroutineContext,
): Flow<T> = map {
withContext(context) {
it.awaitAsOneOrNull() ?: defaultValue
Expand All @@ -77,7 +77,7 @@ fun <T : Any> Flow<Query<T>>.mapToOneOrDefault(

@JvmOverloads
fun <T : Any> Flow<Query<T>>.mapToOneOrNull(
context: CoroutineContext = Dispatchers.Default,
context: CoroutineContext,
): Flow<T?> = map {
withContext(context) {
it.awaitAsOneOrNull()
Expand All @@ -86,7 +86,7 @@ fun <T : Any> Flow<Query<T>>.mapToOneOrNull(

@JvmOverloads
fun <T : Any> Flow<Query<T>>.mapToOneNotNull(
context: CoroutineContext = Dispatchers.Default,
context: CoroutineContext,
): Flow<T> = mapNotNull {
withContext(context) {
it.awaitAsOneOrNull()
Expand All @@ -95,7 +95,7 @@ fun <T : Any> Flow<Query<T>>.mapToOneNotNull(

@JvmOverloads
fun <T : Any> Flow<Query<T>>.mapToList(
context: CoroutineContext = Dispatchers.Default,
context: CoroutineContext,
): Flow<List<T>> = map {
withContext(context) {
it.awaitAsList()
Expand Down

0 comments on commit 7aee4c6

Please sign in to comment.