Does anybody knows when to use asynchronous one-shot queries with Room Android?
@Delete
public ListenableFuture<Integer> deleteUsers(List<User> users);
I am a beginner in the field, I do not know where to find this information. If anybody knows a use case, please share it with us.
Thanks.
This is the UseCase interface that I use for asynchronous one-shot queries with Room:
interface SimpleOneShotUseCase<out Response, out Error, in UseCaseParams> : UseCase<Response, Error, UseCaseParams> {
override suspend operator fun invoke(params: UseCaseParams): Either<Error, Response> =
withContext(Dispatchers.IO) {
run(params = params)
}
suspend fun run(params: UseCaseParams): Either<Error, Response>
}
interface UseCase<out Response, out Error, in UseCaseParams> {
suspend fun observe(params: UseCaseParams): Flow<Either<Error, Response>> = flow { emit(invoke(params)) }
suspend operator fun invoke(params: UseCaseParams): Either<Error, Response>
}