ansman
09/04/2020, 5:14 PMFlow.firstOrNull
restricted to non nullable types? Feels like it'd be useful even with flows with nullable types?Casey Brooks
09/04/2020, 5:16 PMnull
is a valid value, while in the second case, null
is a signal of an erroransman
09/04/2020, 5:19 PMlouiscad
09/04/2020, 5:57 PMtransformWhile
for your use case.ansman
09/04/2020, 5:58 PMlouiscad
09/04/2020, 5:58 PMansman
09/04/2020, 5:59 PMfirstOrNull()
does not have this restriction and neither should Flow
IMOfirstOrNull
does not allow nullable types when the list and array version doeslouiscad
09/04/2020, 6:03 PMfun <E> Flow<E>.firstOrNullForNullables() = transformWhile {
emit(it)
false
}
ansman
09/04/2020, 6:04 PMlouiscad
09/04/2020, 6:06 PMList
version. Might make sense to submit the API change request in GitHub issues then. Good news is that is should be binary compatible if it's accepted.ansman
09/04/2020, 6:06 PM