We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to understanding this architecture by coding example and I followed the project set up till I stuck with that compile time error
Type mismatch required LiveData<TypeVariable(T)> found Unit
in the viewModel I have code like that for register request
fun postRegisterRequest(request: RegisterRequest) { this.registerLiveData = launchOnViewModelScope { this.authRepository.postRegister ({ s -> this.toastLiveData.postValue(s) }, request ) } }
in the repository I have the following code
suspend fun postRegister(error: (String) -> Unit, request: RegisterRequest) = withContext(Dispatchers.IO) { val liveData = MutableLiveData<ResponseWrapper<RegisterResponse>>() isLoading = true networkClient.postRegister( { response -> isLoading = false when (response) { is ApiResponse.Success -> { response.data.whatIfNotNull { liveData.postValue(it) } } is ApiResponse.Failure.Error -> error(response.message()) is ApiResponse.Failure.Exception -> error(response.message()) } },request) }
the network client request look like that
fun postRegister( onResult: (response: ApiResponse<ResponseWrapper<RegisterResponse>>) -> Unit, request: RegisterRequest ) { this.authService.register(request).transform(onResult) }
the authService code
@POST(Urls.REGISTER) fun register(@Body request: RegisterRequest): Call<ResponseWrapper<RegisterResponse>>
what I did wrong and how to make postRegister in the repository return LiveData<TypeVariable(T)> instead of Unit
The text was updated successfully, but these errors were encountered:
@abdulmalekDery Hi, you can return the liveData in the coroutines context.
liveData
suspend fun postRegister(error: (String) -> Unit, request: RegisterRequest) = withContext(Dispatchers.IO) { val liveData = MutableLiveData<ResponseWrapper<RegisterResponse>>() // skip stubs liveData // return liveData }
Sorry, something went wrong.
thanks I will try that
No branches or pull requests
I'm trying to understanding this architecture by coding example and I followed the project set up
till I stuck with that compile time error
Type mismatch required LiveData<TypeVariable(T)> found Unit
in the viewModel I have code like that for register request
in the repository I have the following code
the network client request look like that
the authService code
what I did wrong and how to make postRegister in the repository return LiveData<TypeVariable(T)> instead of Unit
The text was updated successfully, but these errors were encountered: