我们如何在Android中实现promise模式?在这里,我最终遇到了这样的情况:在将用户带到主屏幕之前,我想检查是否加载了所有必要的组件?就像这样
    loadLibA().
        then().
loadLibB().
then().
loadLibc().
then()
}```发布于 2019-10-10 17:49:57
您可以像这样实现promise模式
fun postItem(item: Item) {
preparePostAsync() 
    .thenCompose { token -> 
        submitPostAsync(token, item)
    }
    .thenAccept { post -> 
        processPost(post)
    }
}
fun preparePostAsync(): Promise<Token> {
// makes request an returns a promise that is completed later
return promise 
}https://stackoverflow.com/questions/58319868
复制相似问题