Ahmed Ibrahim
04/14/2020, 6:12 PMuserRepository.streamUser().filterLoggedIn().firstOrNull()
The repository returns a Logged Out user, but I'm only interested in logged in users, I would expect that since this flow becomes an empty flow, then firstOrNull
should return null, right or am I missing something?zak.taccardi
04/14/2020, 6:13 PMfilterLoggedIn()
doesn’t emit anything, and doesn’t complete, so firstOrNull()
won’t emit IIRCAhmed Ibrahim
04/14/2020, 6:14 PMfun Flow<UserResult>.filterLoggedIn(): Flow<UserResult.LoggedIn> =
filterIsInstance()
That's the implementation of it, it is just a mere filterIsInstance
octylFractal
04/14/2020, 6:14 PMstreamUser()
completing, otherwise how would it know if it's empty?Ahmed Ibrahim
04/14/2020, 6:19 PMuserRepository.streamUser().take(1).filterLoggedIn().firstOrNull()
and it is working as expected, thanks everyone.zak.taccardi
04/14/2020, 6:19 PMuserRepository.streamUser().firstOrNull { .. }
zak.taccardi
04/14/2020, 6:20 PMoctylFractal
04/14/2020, 6:20 PMzak.taccardi
04/14/2020, 6:20 PMzak.taccardi
04/14/2020, 6:20 PM