验证中...
rxjsAjaxLikePromiseAll.js
Raw Copy
import {
zip
} from 'rxjs';
import {
ajax
} from 'rxjs/ajax';
import {
map,
delay
} from 'rxjs/operators'
function rxjsAjaxLikePromiseAll() {
const ajax1$ = ajax({
url: 'https://www.duokan.com/store/v0/web/query/hint?s=多',
method: 'get'
}).pipe(map(res => res.response.items));
const ajax2$ = ajax({
url: 'https://www.duokan.com/store/v0/web/query/hint?s=女',
method: 'get'
}).pipe(map(res => res.response.items), delay(5000));
zip(ajax1$, ajax2$)
.pipe(
map(data => {
return [...data[0], ...data[1]]
})
)
.subscribe(data => {
console.warn(data);
console.log(`共${data.length}条数据`);
})
}

Comment list( 0 )

Sign in for post a comment

Help Search

191139_cd20d5fd_5186603 191143_ebef6f8d_5186603