简体   繁体   English

当我们在rxjava中使用观察者时,真正发生了什么?

[英]what really happens when we are using observer in rxjava?

I like to know what is really going on internally while we use a observer in RxJava, and how do the subscriber get all the data stream from the observer. 我想知道在RxJava中使用观察器时内部到底发生了什么,以及订户如何从观察器获取所有数据流。

Thanking you all in advance. 预先谢谢大家。

You can think of RxJava as an extreme generalization of the Observer pattern . 您可以将RxJava视为Observer模式的极端概括。 You essentially register a call-back with the thing you are observing (the observable). 本质上,您要使用您正在观察的事物(可观察的事物)注册一个回调。 The observable item calls onNext() whenever it has an item it wants to emit, then onComplete() when it is done. 可观察项在有要发射的项时调用onNext() ,然后在完成时调用onComplete()

All of the rest of the RxJava implementation supports flow control, composition of call-backs, allowing multiple call-backs on an observable, time-distortions, combining different observables, and thread management. 所有其余的RxJava实现都支持流控制,回调的组合,允许在可观察的时间上进行多次回调,时间扭曲,组合不同的可观察对象和线程管理。

If you really want to know the internals, you can read the code. 如果您真的想了解内部结构,则可以阅读代码。 More importantly, you can read the narratives of David Karnok, a principal architect and developer of RxJava and reactive streams. 更重要的是,您可以阅读RxJava和响应流的首席架构师和开发人员David Karnok的叙述。 Here is a sample blog describing internals of connected observables. 这是一个示例博客,描述了连接的可观察对象的内部。

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

相关问题 当我更改 LiveData 的观察者时会发生什么 - What happens when i change the observer of a LiveData 在java中传递对象时会发生什么? - what really happens when passing objects in java? 在Java中加载类时真正发生了什么? - What really happens when loading a class in java? RxJava平面图:当其中一个可观测的完整对象完成时会发生什么? - RxJava flat map: what happens when one of the resulting observable complete? 当我们提交时到底发生了什么? - What happens exactly when we commit? 在Java中,当一个接口“扩展”另一个接口时会发生什么? - In Java, what really happens when an interface “extends” another interface? Java多线程-访问“锁定”对象时真正发生了什么? - Java Multithreading - What Really Happens When Accessing A “Locked” Object? 初始化未初始化的实例变量时会发生什么? - What really happens when an uninitialized instance variable is initialized? 当您单击<button>/</button>时,实际发生了什么 <button><input></button> <button>在HTML中?</button> - What really happens when you click the <button>/<input> in HTML? Java中的继承真的发生了什么? - What really happens on inheritance in Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM