为什么下面的代码返回包含promise
的{{1}}?
observable
我希望代码能够:
const queryApi = (request: AxiosRequestConfig): Observable<ParsedData> => {
return new Observable(observer => {
axios(request).then(response => {
observer.next(response);
observer.complete();
}).catch(error => {
observer.error(error);
})
}).pipe(map(value => {
const parser = new Parser(name);
const response = value as AxiosResponse;
return parser.parse(response.data);
}));
}
const sourcePromise: Promise<ParsedData> = queryApi(request, 1).toPromise();
await sourcePromise.then(source$ => {
source$.subscribe((value: ParsedData) => console.log(JSON.stringify(value, null, 2)));
}).catch(error => console.log(error));
axios
解析的值创建一个可观察对象axios
运算符可观察到的管道,该操作符返回map
observable
转换为observable
promise
以公开数据。答案 0 :(得分:0)
p <- ggplot(mpg, aes(class, hwy))
p + geom_boxplot()+
annotate("text", x = c(1:7), y=-10, label = paste(1:7*10, "mpg"), cex=3)