无法分配io.reeactivex.flowable< io.reeactivex.maybe>到:io.reeactivex.flowable< object>

发布于 2025-01-31 22:08:05 字数 709 浏览 4 评论 0原文

希望你们都做意志。我对此非常陌生,我一直在遇到不兼容类型的问题。

Flowable<Boolean> checkTriggerDaily() {

        List<Bson> fields = new ArrayList<Bson>();
        fields.add(exists("dueDate", true));
        Bson filter = and(fields);

        Flowable.fromPublisher(marketplaceMongoService.getCollection().find(filter)).map{ third ->
                    getTheReport(third.id).flatMap { size ->
                     TaskService.createTasks(size).toFlowable().flatMap({})
                    }
                }
    }

我一直在标题上遇到相同的错误。此功能的作用是循环通过mongo collection,并致电getThereport每个项目。 getThereportreturns,我将其处理为createTasks功能。

getThereport-&gt;返回也许 createTasks - &gt;返回也许

Hope You're all doing will. I'm very new to this and I keep getting issues with incompatible types.

Flowable<Boolean> checkTriggerDaily() {

        List<Bson> fields = new ArrayList<Bson>();
        fields.add(exists("dueDate", true));
        Bson filter = and(fields);

        Flowable.fromPublisher(marketplaceMongoService.getCollection().find(filter)).map{ third ->
                    getTheReport(third.id).flatMap { size ->
                     TaskService.createTasks(size).toFlowable().flatMap({})
                    }
                }
    }

I keep getting the same error on the title. What this function does is loop through a mongo collection and call getTheReport every item. What the getTheReportReturns, i process it to createTasks function.

getTheReport -> returns Maybe
createTasks -> returns Maybe

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

面犯桃花 2025-02-07 22:08:05

由于

getTheReport(third.id).flatMap { size ->
    TaskService.createTasks(size).toFlowable().flatMap({})
}

结果是Flotalbe,因此您应该调用FlatMap而不是MAP,以便将内部函数发射的对象被解开为A flat /em>结果:

Flowable<Boolean> checkTriggerDaily() {

    List<Bson> fields = new ArrayList<Bson>();
    fields.add(exists("dueDate", true));
    Bson filter = and (fields);

    Flowable.fromPublisher(marketplaceMongoService.getCollection().find(filter))
        .flatMap { third -> // flatMap instead of map
            getTheReport(third.id).flatMap { size ->
                TaskService.createTasks(size).toFlowable().flatMap({})
            }
        }
}

Since

getTheReport(third.id).flatMap { size ->
    TaskService.createTasks(size).toFlowable().flatMap({})
}

result is a Flowalbe, you should call flatMap instead of map so that the internal function emitted objects get unpacked into a flat result:

Flowable<Boolean> checkTriggerDaily() {

    List<Bson> fields = new ArrayList<Bson>();
    fields.add(exists("dueDate", true));
    Bson filter = and (fields);

    Flowable.fromPublisher(marketplaceMongoService.getCollection().find(filter))
        .flatMap { third -> // flatMap instead of map
            getTheReport(third.id).flatMap { size ->
                TaskService.createTasks(size).toFlowable().flatMap({})
            }
        }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文