RxParse

Additional

Language
Java
Version
2.0.4 (Feb 23, 2017)
Created
Jan 12, 2015
Updated
Aug 31, 2017 (Retired)
Owner
Andrew Chen (yongjhih)
Contributors
Wendly
Henry Chang (changyuheng)
Andrew Chen (yongjhih)
Pascal Hartig (passy)
The Gitter Badger (gitter-badger)
John Cordeiro (johncordeiro)
York Tsai (ynntk4815)
ecdpalma
Daniel San Ferreira da Rocha (danielsanfr)
9
Activity
Badge
Generate
Download
Source code

Advertisement

RxParse

javadoc:

  • rxparse:
  • rxparse-facebook-v3:
  • rxparse-facebook-v4:

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.