In my repository class I am calling webservice. If query is not null then returning the result as flowable, if query is null then return null . Then in my ViewModel I am converting the flowable to LiveData.
Below is the code snippet:
In myRepository class:
fun fetchToDosFromServer(fullQueryString: String?)
: Flowable<GitResult>?
{
if(fullQueryString.length>0)
{ //call webservice- which return observable<GitResult>
var returnedResult = myWebServiceCall()
return returnedData.toFlowable(BackpressureStrategy.BUFFER)
}
else
return null
}
In myViewModel class:
fun getReposFromServer()
{
val resultFromApiCall_flowable : Flowable<GitResult>? = mainRepository.fetchToDosFromServer("q=2")
val source: LiveData<GitResult> = LiveDataReactiveStreams.fromPublisher(resultFromApiCall_flowable)
}
but its showing compile time error when trying to convert flowable to LiveData in myViewModel class. In the line:
LiveDataReactiveStreams.fromPublisher(resultFromApiCall_flowable)
the error is:
Error: required Flowable , found Flowable?
how do I solve it?