RxAndroid

RxJava bindings for Android

  • 所有者: ReactiveX/RxAndroid
  • 平台:
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

RxAndroid: Reactive Extensions for Android

Android specific bindings for RxJava 2.

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.

Communication

Since RxAndroid is part of the RxJava family the communication channels are similar:

Binaries

implementation 'io.reactivex.rxjava2:rxandroid:2.1.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.
// (see https://github.com/ReactiveX/RxJava/releases for latest 2.x.x version)
implementation 'io.reactivex.rxjava2:rxjava:2.x.x'
  • RxAndroid:
  • RxJava:

Additional binaries and dependency information for can be found at 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.

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.

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:

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.

Observing on arbitrary loopers

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:

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.

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues.
For general usage questions please use the mailing list or 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.

概览

名称与所有者ReactiveX/RxAndroid
主编程语言Java
编程语言Java (语言数: 1)
平台
许可证Apache License 2.0
发布数22
最新版本名称3.0.2 (发布于 2022-11-09 15:03:20)
第一版名称v0.21.0 (发布于 2014-09-30 23:33:46)
创建于2014-08-19 03:46:38
推送于2024-04-15 16:35:31
最后一次提交
星数19.9k
关注者数1k
派生数3k
提交数553
已启用问题?
问题数350
打开的问题数1
拉请求数183
打开的拉请求数0
关闭的拉请求数61
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?
去到顶部