RxBolts
![Methods Count](https://img.shields.io/badge/Methods and size-core: 54 | deps: 4111 | 6 KB-e91e63.svg)
Reactive Bolts-Android. Allow convert Task<T>
to Observable<T>
.
Usage
TaskObservable.defer():
TaskObservable.defer(() -> Task.forResult("Hello, world!")).subscribe(it -> {
System.out.println(it);
}
);
Take 5 users using Parse:
TaskObservable.defer(() -> ParseUser.getQuery().findInBackground()).flatMap(Observable::from).take(5).subscribe(user -> {
System.out.println(user.getObjserId());
}
);
Update location of 5 users using Parse:
TaskObservable.defer(() -> ParseUser.getQuery().findInBackground()).flatMap(Observable::from).take(5).flatMap(user -> {
user.put("location", "Taipei");
return TaskObservable.defer(() -> user.saveInBackground());
}
).subscribe();
Error handling
Failed:
TaskObservable.defer(() -> Task.forError(new RuntimeException("An error message."))).subscribe(it -> {
}
, e -> {
e.printStackTrace();
// RuntimeException
}
);
AppLinks
AppLinkObservable.navigate(context, url, resolver);
AppLinkNavigation.setDefaultResolver(resolver);
AppLinkObservable.navigate(context, url);
Sample code
Installation
For RxJava2
Via jitpack.io
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.yongjhih.RxBolts:rxbolts2:-SNAPSHOT'
//compile 'com.github.yongjhih.RxBolts:rxbolts2-taks:-SNAPSHOT'
//compile 'com.github.yongjhih.RxBolts:rxbolts2-applinks:-SNAPSHOT'
}
For RxJava1
via jcenter
repositories {
jcenter()
}
dependencies {
compile 'com.infstory:rxbolts:1.0.1'
}
Or via jitpack.io
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.yongjhih.RxBolts:rxbolts:-SNAPSHOT'
//compile 'com.github.yongjhih.RxBolts:rxbolts-tasks:-SNAPSHOT'
//compile 'com.github.yongjhih.RxBolts:rxbolts-applinks:-SNAPSHOT'
}
Development and deploy to jcenter
rxbolts:
./gradlew :rxbolts:build :rxbolts:bintrayUpload
See Also
ref.
LICENSE
Copyright 2015 8tory, Inc.
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.