I am using Room Database from the new Architecture components in my project. I am adding some data through dao, but when trying to retrieve it I am not getting it. Can you pleas
I make like this(I use coroutines suspend
):
class SaveVehicle(val repository: RepositoryInterface) {
suspend fun invoke(vehicleListItem: VehicleListItem): VehicleListItem =
with(vehicleListItem) {
also {
repository.saveVehicle(vehicleListItem)
}
}
}
Kotlin Doc
inline fun T.also(block: (T) -> Unit): T
Calls the specified function block with this value as its argument and returns this value.
also
is good for performing some actions that take the context object as an argument. Use also
for actions that need a reference rather to the object than to its properties and functions, or when you don't want to shadow this reference from an outer scope.
You can check my example in GitHub: