kendo的Kendo UI使用Observable<Observable<GridDataResult>>
作为网格数据的返回类型
getData(model: State): Observable<Observable<GridDataResult>> {
return this.mainService.post(`http://localhost:41689/api/Data/GetData`, model);
}
然后称呼它
public view: Observable<GridDataResult> | undefined;
public gridState: State = {
sort: [],
skip: 0,
take: 10
};
public getData() {
return this.sampleTypeService.getData(this.gridState).subscribe(
res => {
this.view = res;
}
);
}
这有效。但是在单元测试中,我无法在view
中获取数据,因为它是可观察的。
如果我更改
public view: Observable<GridDataResult> | undefined;
到
public view: GridDataResult | undefined;
和getData到
getData(model: State): Observable<GridDataResult> {
return this.mainService.post(`http://localhost:41689/api/Data/GetData`, model);
}
有效。现在,我可以对返回的数据进行单元测试了。
我想知道这两者之间有什么区别