lastVersionOf
Finds the last occurrence of a specific data type in the list.
This extension function is useful for testing scenarios where you need to find the most recent occurrence of a specific data type from a stream of captured data transmissions.
Receiver
List of data transmissions to search through
Return
The last data transmission of type T, or null if none exists
Example usage:
val dataStream = listOf(
UserData.Loading,
UserData.LoggedIn(user),
UserData.ProfileUpdated(newProfile)
)
val lastUserData = dataStream.lastVersionOf<UserData.LoggedIn>()
assertNotNull(lastUserData)
Parameters
The type of data to search for
Finds the last occurrence of a specific effect type in the list.
This extension function is useful for testing scenarios where you need to find the most recent occurrence of a specific effect type from a stream of captured effect transmissions.
Receiver
List of effect transmissions to search through
Return
The last effect transmission of type T, or null if none exists
Example usage:
val effectStream = listOf(
LoadingEffect.Show,
NetworkEffect.Request(url),
LoadingEffect.Hide,
NavigationEffect.Navigate(screen)
)
val lastLoadingEffect = effectStream.lastVersionOf<LoadingEffect.Hide>()
assertNotNull(lastLoadingEffect)
Parameters
The type of effect to search for