是否可以连接多个可观察对象?
例如:我有 3 个功能:
ensureUserLogged():Observable<boolean>
createEntity():Observable<Entity>
checkEntity():Observable<boolean>
我想做类似的事情:
Observable.combine (ensureUserLogged(), createEntity(), checkEntity()).subscribe (
checkEntityResult => console.log (checkEntityResult),
error => console.log (error)
);
或类似的东西:
ensureUserLogged().then (logged => createEntity()).then (newEntity => checkEntity ())...
否则我需要写一个丑陋的金字塔:
ensureUserLogged().subscribe (
res => {
createEntity ().subscribe (
res => {
checkEntity ().subscribe (
res => { console.log ("I'm finally here") },
error {}
)
},
err => {
}
);
},
err => {
}
)
有什么东西可以实现我的意志吗?
谢谢