Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use awaitSingle operator instead of awaitFirst #1355

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ package org.springframework.data.r2dbc.core

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.asFlow
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlinx.coroutines.reactive.awaitSingle
import kotlinx.coroutines.reactor.awaitSingleOrNull

/**
* Extensions for [ReactiveSelectOperation].
*
* @author Mark Paluch
* @author Mark Paluch, George Papadopoulos
* @since 1.1
*/

Expand All @@ -49,7 +49,7 @@ suspend inline fun <reified T : Any> ReactiveSelectOperation.TerminatingSelect<T
* Nullable Coroutines variant of [ReactiveSelectOperation.TerminatingSelect.one].
*/
suspend inline fun <reified T : Any> ReactiveSelectOperation.TerminatingSelect<T>.awaitOneOrNull(): T? =
one().awaitFirstOrNull()
one().awaitSingleOrNull()

/**
* Non-nullable Coroutines variant of [ReactiveSelectOperation.TerminatingSelect.first].
Expand All @@ -61,7 +61,7 @@ suspend inline fun <reified T : Any> ReactiveSelectOperation.TerminatingSelect<T
* Nullable Coroutines variant of [ReactiveSelectOperation.TerminatingSelect.first].
*/
suspend inline fun <reified T : Any> ReactiveSelectOperation.TerminatingSelect<T>.awaitFirstOrNull(): T? =
first().awaitFirstOrNull()
first().awaitSingleOrNull()

/**
* Coroutines variant of [ReactiveSelectOperation.TerminatingSelect.count].
Expand Down