gpt4 book ai didi

reactive-programming - Flow API 是否正在取代 Observer 和 Observable

转载 作者:行者123 更新时间:2023-12-03 13:31:39 25 4
gpt4 key购买 nike

在 Java 9 中,Flow API替换 ObserverObservable ?如果不是,那是什么?

最佳答案

The new Flow API被设计为 reactive stream 的共同点像 RxJava 和 Reactive X 这样的库。在 Java 9 上构建,它们可以让它们的类型扩展新的接口(interface)(或者这样想)。虽然在 JDK 中使用 API 当然很有吸引力,但在 Java 9 中并非如此,并且没有具体的计划来引入它(据我所知)。

关于ObserverObservable the issue which triggered the deprecation状态:

Application developers should consider using java.beans for a richer change notification model. Or they should consider constructs in java.util.concurrent such as queues or semaphores to pass messages among threads, with reliable ordering and synchronization properties.



这些是针对应用程序开发人员编写新代码的建议。它没有提供有关更新现有代码或在 JDK 中做什么的建议。我想原因是这两种情况都应该保持原样。

请注意,Java 不使用 @Deprecated必然意味着“将被删除”。相反,它也可能意味着“使用更好的替代品”,我认为这里就是这种情况。所以用几句话回答你的问题:

In Java 9 does Flow API replace Observer and Observable



不。

and if it doesn't what does.



没有。

关于reactive-programming - Flow API 是否正在取代 Observer 和 Observable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42532779/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com