RxParse
javadoc:
Usage of RxJava2
find
<T extends ParseObject> Observable<T> ParseObservable.find(ParseQuery<T>);
Before:
ParseUser.getQuery().findInBackground(new FindCallback() {
@Override
public done(ParseUser user, ParseException e) {
if (e == null) System.out.println(user);
}
}
);
After:
Observable<ParseUser> users = ParseObservable.find(ParseUser.getQuery());
users.subscribe(user -> System.out.println(user.getObjectId()));
Observable<ParseUser> users = ParseObservable.find(ParseUser.getQuery().setLimit(1000));
count
Before:
ParseUser.getQuery().countInBackground(new CountCallback() {
@Override
public done(int count, ParseException e) {
if (e == null) System.out.println(count);
}
}
);
After:
Single<Integer> count = ParseObservable.count(ParseUser.getQuery());
count.subscirbe(c -> System.out.println(c));
Sign in with facebook
After:
ParseFacebookObservable.logIn(Arrays.asList("public_profile", "email"), activity).subscribe(user -> {
System.out.println("user: " + user);
}
);
Get my commented posts
Before:
ParseComment.getQuery().whereEqualTo("from", ParseUser.getCurrentUser()).findInBackground(new FindCallback<ParseComment> {
@Override
public done(List<ParseComment> comments, ParseException e) {
if (e != null) return;
ParsePost.getQuery().whereContainedIn("comments", comments).findInBackground(new FindCallback<ParsePost>() {
@Override
public done(List<ParsePost> posts, ParseException e2) {
if (e2 != null) return;
// ...
}
}
);
}
}
);
After:
ParseObservable.find(ParseComment.getQuery().whereEqualTo("from", ParseUser.getCurrentUser()))
.toList()
.flatMap(comments -> ParseObservable.find(ParsePost.getQuery().whereContainedIn("comments", comments)))
.subscribe(posts -> {
}
);
Parse cloud code: ParseObservable.callFunction()
Map<String, Object> params = new HashMap<>();
params.put("accessToken", googleToken());
ParseObservable.callFunction("signInWithGoogle", params).subscribe(parseToken -> {
}
);
Usage of RxJava1
count
Before:
ParseUser.getQuery().countInBackground(new CountCallback() {
@Override
public done(int count, ParseException e) {
if (e == null) System.out.println(count);
}
}
);
After:
Observable<Integer> count = ParseObservable.count(ParseUser.getQuery());
count.subscirbe(c -> System.out.println(c));
Installation
RxJava2
via jitpack.io
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.yongjhih.RxParse:rxparse2:2.1.0'
//compile 'com.github.yongjhih.RxParse:rxparse2-facebook-v3:2.1.0' // if needed
//compile 'com.github.yongjhih.RxParse:rxparse2-facebook-v4:2.1.0' // if needed
// SNAPSHOT
//compile 'com.github.yongjhih.RxParse:rxparse2:-SNAPSHOT'
//compile 'com.github.yongjhih.RxParse:rxparse2-facebook-v3:-SNAPSHOT' // if needed
//compile 'com.github.yongjhih.RxParse:rxparse2-facebook-v4:-SNAPSHOT' // if needed
}
via jcenter
repositories {
jcenter()
}
dependencies {
compile 'com.infstory:rxparse2:2.1.0'
//compile 'com.infstory:rxparse2-facebook-v3:2.1.0' // if needed
//compile 'com.infstory:rxparse2-facebook-v4:2.1.0' // if needed
}
RxJava1
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.yongjhih.RxParse:rxparse:2.0.3'
//compile 'com.github.yongjhih.RxParse:rxparse-facebook-v3:2.0.3' // if needed
//compile 'com.github.yongjhih.RxParse:rxparse-facebook-v4:2.0.3' // if needed
}
via jcenter
repositories {
jcenter()
}
dependencies {
compile 'com.infstory:rxparse:2.0.3'
//compile 'com.infstory:rxparse-facebook-v3:2.0.3' // if needed
//compile 'com.infstory:rxparse-facebook-v4:2.0.3' // if needed
}
Test
./gradlew clean :rxparse:assembleDebug :rxparse:testDebug --tests='*.ParseObservableTest'
Deploy
./gradlew :rxparse2:build :rxparse2:bintrayUpload ./gradlew :rxparse2-facebook-v3:build :rxparse2-facebook-v3:bintrayUpload ./gradlew :rxparse2-facebook-v4:build :rxparse2-facebook-v4:bintrayUpload
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.