Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试对n项目进行一些异步工作,并等待所有项目完成后再继续。
n
我应该在该whatfunc?位置放置什么以使订阅的 onComplete 触发一次?
whatfunc?
Observable.range(0, n) .<whatfunc?>({ s -> doAsyncWorkThatReturnsObservable(s) }) .(other?) .subscribe({println "All complete"})
谢谢
平面图
确保为订阅中的正确参数提供闭包。链接示例已调整以适合您提供的示例:
Observable.range(0, n) .flatMap({n -> doAsyncWorkThatReturnsObservable(n)}) .subscribe( { println(it); }, // onNext { println("Error: " + it.getMessage()); }, // onError { println("Sequence complete"); } // onCompleted );