简体   繁体   English

RxJava2。 Flowable的行为方式与Observable相同?

[英]RxJava2. Flowable to behave same way as Observable does?

It seems like mental overhead to use both Observable and Flowable in the same project for RXJava 2. 好像精神开销同时使用ObservableFlowable在为同一个项目RXJava 2。

Say to distinguish in the interfaces that this method return Observable so there is not back-pressure this one does so it is with back-pressure support. 要在接口中区分一下该方法返回的是Observable,因此该方法没有背压,因此具有背压支持。

But in the end of the day we can just use Flowable to make things simpler? 但是最终,我们可以使用Flowable使事情变得更简单吗?

Then: 然后:

Can I make Flowable to be faster to turn off pressure to behave same way as Observable does? 我可以使Flowable更快地关闭压力,使其行为与Observable相同吗?

My answer to myself: use Flowable everywhere. 我对自己的回答:到处使用Flowable。 For all API that exposed themselves through the Net. 对于所有通过网络公开的API。

My use case: I use RX Java to defining RX API to the Web and itneracting with other microservices by Net. 我的用例:我使用RX Java来定义Web的RX API,并通过Net与其他微服务进行交互。

From my understanding, the projectreactor https://projectreactor.io/ (another rx iml) project there is even no question whether to go with backpressure or not. 根据我的理解,projectreactor https://projectreactor.io/ (另一个rx iml)项目甚至没有疑问是否要使用背压。 It is there for all Flux 所有助焊剂都在那里

Going back to RxJava2. 回到RxJava2。 It seems to me that in the RX Java it was decided to keep Observable for the backward compatibility purposes primary. 在我看来,在RX Java中,出于向后兼容的目的,决定将Observable保持不变。 (there is no good explanation why not) (没有很好的解释为什么不这样)

And when it comes to HTTP I found that I need it even for smaller sets. 当涉及到HTTP时,我发现即使是较小的集合也需要它。 Usually. 通常。 Event if I return less than 1000 items to the client it does not mean that it can handle it at once (it can be busy doing other stuff), so I would go with backpressure. 如果我向客户退回的商品少于1000件 ,这并不意味着它可以立即处理它(它可能正忙于做其他事情),所以我会背负压力。

So I do not won't to overcomplicate things / api / code, will go with Flowable everywhere until I see any of Observable. 因此,我不会过度复杂化事物/ api /代码,在我看到任何Observable之前,Flowable会随处可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM