RxJava四个基础接口
2018-06-18 03:49:55来源:未知 阅读 ()
Publisher
Subscriber
Subscription
Processor
-----------------------------------
public interface Publisher<T> { /** * Request {@link Publisher} to start streaming data. * <p> * This is a "factory method" and can be called multiple times, each time starting a new {@link Subscription}. * <p> * Each {@link Subscription} will work for only a single {@link Subscriber}. * <p> * A {@link Subscriber} should only subscribe once to a single {@link Publisher}. * <p> * If the {@link Publisher} rejects the subscription attempt or otherwise fails it will * signal the error via {@link Subscriber#onError}. * * @param s the {@link Subscriber} that will consume signals from this {@link Publisher} */ public void subscribe(Subscriber<? super T> s); }
public interface Subscriber<T> { /** * Invoked after calling {@link Publisher#subscribe(Subscriber)}. * <p> * No data will start flowing until {@link Subscription#request(long)} is invoked. * <p> * It is the responsibility of this {@link Subscriber} instance to call {@link Subscription#request(long)} whenever more data is wanted. * <p> * The {@link Publisher} will send notifications only in response to {@link Subscription#request(long)}. * * @param s * {@link Subscription} that allows requesting data via {@link Subscription#request(long)} */ public void onSubscribe(Subscription s); /** * Data notification sent by the {@link Publisher} in response to requests to {@link Subscription#request(long)}. * * @param t the element signaled */ public void onNext(T t); /** * Failed terminal state. * <p> * No further events will be sent even if {@link Subscription#request(long)} is invoked again. * * @param t the throwable signaled */ public void onError(Throwable t); /** * Successful terminal state. * <p> * No further events will be sent even if {@link Subscription#request(long)} is invoked again. */ public void onComplete(); }
public interface Subscription { /** * No events will be sent by a {@link Publisher} until demand is signaled via this method. * <p> * It can be called however often and whenever needed—but the outstanding cumulative demand must never exceed Long.MAX_VALUE. * An outstanding cumulative demand of Long.MAX_VALUE may be treated by the {@link Publisher} as "effectively unbounded". * <p> * Whatever has been requested can be sent by the {@link Publisher} so only signal demand for what can be safely handled. * <p> * A {@link Publisher} can send less than is requested if the stream ends but * then must emit either {@link Subscriber#onError(Throwable)} or {@link Subscriber#onComplete()}. * * @param n the strictly positive number of elements to requests to the upstream {@link Publisher} */ public void request(long n); /** * Request the {@link Publisher} to stop sending data and clean up resources. * <p> * Data may still be sent to meet previously signalled demand after calling cancel as this request is asynchronous. */ public void cancel(); }
public interface Processor<T, R> extends Subscriber<T>, Publisher<R> { }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:springMVC的请求流程
下一篇:String常用的方法
- 04.Java基础语法 2020-06-11
- 1-Java基础回顾整理_01 2020-06-10
- Java基础语法菜鸟教程笔记 2020-06-10
- Java基础复习——类和对象 2020-06-09
- 计算机基础到底是哪些基础?为什么很重要! 2020-06-08
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash