Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

RxJava bindings for Android

License

NotificationsYou must be signed in to change notification settings

webcashbookupi-commits/RxAndroid

 
 

Repository files navigation

Android specific bindings forRxJava 3.

This module adds the minimum classes to RxJava that make writing reactive components in Androidapplications easy and hassle-free. More specifically, it provides aScheduler that schedules onthe main thread or any givenLooper.

Communication

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

Binaries

dependencies {    implementation'io.reactivex.rxjava3:rxandroid:3.0.2'// 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 3.x.x version)    implementation'io.reactivex.rxjava3:rxjava:3.1.5'}
  • RxAndroid:
  • RxJava:

Additional binaries and dependency information for can be found atsearch.maven.org.

Snapshots of the development version are available in Sonatype's snapshots repository.

repositories {    mavenCentral()    maven {        url'https://oss.sonatype.org/content/repositories/snapshots/'    }}dependencies {    implementation'io.reactivex.rxjava3:rxandroid:3.1.0-SNAPSHOT'}

Build

To build:

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

Further details on building can be found on the RxJavaGetting Started page of the wiki.

Sample usage

A sample project which provides runnable code examples that demonstrate uses of the classes in thisproject is available in thesample-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'sresult or outcome on the main thread. Using vanilla Android, this would typically be accomplished with anAsyncTask. With RxJava instead you would declare yourObservable 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 theObservable on a new thread, and emit results throughonNext on the main thread.

Observing on arbitrary loopers

The previous sample is merely a specialization of a more general concept: binding asynchronouscommunication to an Android message loop, orLooper. In order to observe anObservable on an arbitraryLooper, create an associatedScheduler by callingAndroidSchedulers.from:

LooperbackgroundLooper =// ...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 throughonNext on whatever thread isrunningbackgroundLooper.

Bugs and Feedback

For bugs, feature requests, and discussion please useGitHub Issues.For general usage questions please use themailing list orStackOverflow.

LICENSE

Copyright 2015 The RxAndroid authorsLicensed 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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.

About

RxJava bindings for Android

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java100.0%

[8]ページ先頭

©2009-2025 Movatter.jp