RxAndroid官方简短介绍

RxAndroid: Reactive Extensions for Android

Android specific bindings for RxJava.
Android特定的RxJava绑定。

This module adds the minimum classes to RxJava that make writing reactive components in Android applications easy and hassle-free. More specifically, it provides a Scheduler that schedules on the main thread or any given Looper.
此模块将最少的类添加到RxJava,使得在Android应用程序中编写响应使式组件简单、无忧。 具体说,它提供了在主线程或任何给定Looper上调度的Scheduler

Communication

联系

Since RxAndroid is part of the RxJava family the communication channels are similar:
由于RxAndroid是RxJava家族的一部分,因此联络途径类似:

Binaries

二进制文件

compile 'io.reactivex:rxandroid:1.2.1'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
// 因为RxAndroid版本很少,所以明确建议您使用RxJava的最新版本进行错误修复和新功能开发。
compile 'io.reactivex:rxjava:1.1.6'

Additional binaries and dependency information for can be found at http://search.maven.org.
有关其他二进制文件和依赖项信息,请访问http://search.maven.org

Build

编译

To build:
编译:

$ git clone git@github.com:ReactiveX/RxAndroid.git
$ cd RxAndroid/
$ ./gradlew build

Further details on building can be found on the RxJava Getting Started page of the wiki.
关于编译的更多细节可以在RxJava的wiki入门页面找到。

Sample usage

示例用法

A sample project which provides runnable code examples that demonstrate uses of the classes in this project is available in the sample-app/ folder.
sample-app /文件夹中提供了一个示例项目,它提供了可运行的代码示例,演示了此项目中类的使用。

Observing on the main thread

观察主线程

One of the most common operations when dealing with asynchronous tasks on Android is to observe the task’s result or outcome on the main thread. Using vanilla Android, this would typically be accomplished with an AsyncTask. With RxJava instead you would declare your Observable to be observed on the main thread:
在Android上处理异步任务时最常见的操作之一是在主线程上观察任务的结果。 使用原生Android,我们通常使用AsyncTask来实现。 使用RxJava,你可以声明你的Observable在主线程上进行观察:

Observable.just("one", "two", "three", "four", "five")
        .subscribeOn(Schedulers.newThread())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(/* an Observer */);

This will execute the Observable on a new thread, and emit results through onNext on the main thread.
这将在新线程上执行Observable,并通过onNext在主线程上发出结果。

Observing on arbitrary loopers

观察任意的Looper

The previous sample is merely a specialization of a more general concept: binding asynchronous communication to an Android message loop, or Looper. In order to observe an Observable on an arbitrary Looper, create an associated Scheduler by calling AndroidSchedulers.from:
前面仅仅是通用概念下特定化的一个例子:将异步通信绑定到Android消息循环或Looper。 为了观察任意LooperObservable,通过调用AndroidSchedulers.from创建一个相关联的Scheduler

Looper backgroundLooper = // ...
Observable.just("one", "two", "three", "four", "five")
        .observeOn(AndroidSchedulers.from(backgroundLooper))
        .subscribe(/* an Observer */)

This will execute the Observable on a new thread and emit results through onNext on whatever thread is running backgroundLooper.
这将在新线程上执行Observable,并通过onNext在任何运行backgroundLooper的线程上发出结果。

Bugs and Feedback

错误和反馈

For bugs, feature requests, and discussion please use GitHub Issues. For general usage questions please use the mailing list or StackOverflow.
对于错误、功能需求和讨论,请使用GitHub Issues。 对于一般的使用问题,请使用邮件列表或StackOverflow。

LICENSE

许可

Copyright 2015 The RxAndroid authors

Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.


项目地址:https://github.com/ReactiveX/RxAndroid.git
文章地址:https://github.com/ReactiveX/RxAndroid/blob/1.x/README.md
译:刘炳昭 http://blog.csdn.net/liubingzhao

生词表:

生词表

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值