如何从接口中的方法返回类型对象的Observable [英] How to return Observable of type object from a method in the interface
本文介绍了如何从接口中的方法返回类型对象的Observable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习科特林.如下代码所示,我创建了一个对象模型和一个接口.接口中的方法应返回
I am learning kotlin. as shown in the code below, i created a object Model and an interface. the method in the interface should return
Model.Result
但是当我将上述数据类型包装到Observable中时,出现以下错误
but when I wrap the aforementioned data type in Observable I receive the following error
No type argument expected for class observable
请让我知道如何解决此问题...当我尝试在google中找到一些解决方案但不起作用
please let me know how fix this issue...as i tried to find some solution in google but it does not work
对象:
public object Model {
data class Result(val query: Query)
data class Query(val searchinfo: SearchInfo)
data class SearchInfo(val totalhits: Int)
}
界面:
interface WikiService {
fun method1(): Observable<Model.Result>//No type argument expected for class observable
推荐答案
您正在使用的java.util.Observable
不接受任何参数.
You are using java.util.Observable
that doesn't accept any paramter.
您应该导入已参数化的io.reactivex.Observable
.
You should import io.reactivex.Observable
that is parametrized.
这篇关于如何从接口中的方法返回类型对象的Observable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文