vertx 3在执行vertex.fileSytem操作链时避免嵌套的Handler <asyncresult>

时间:2016-11-22 10:08:57

标签: asynchronous functional-programming java-8 filesystems vert.x

在vertx 3中,我想做几个vertx.fileSystem()操作, 每个人都取决于前一个人的成功。

如何避免以嵌套Handler<AsyncResult>

结束
this.vertx.fileSystem().mkdir("my-temp", res -> {
            if (res.succeeded()) {
                this.vertx.fileSystem().move("/tmp/file.txt", "my-temp/file.txt", res2 -> {
                    if (res2.succeeded()) {
                        // having maybe even more nested Handler<AsyncResult>
                    }
                });
            }
        });

1 个答案:

答案 0 :(得分:3)