rxFirebase
RxJava wrapper on Google's Firebase for Android library.
Usage
Library provides set of static methods of classes:
- rxFirebaseAuth
- rxFirebaseDatabase
Authentication:
According to Firebase API there are 4 different authentication methods:
- signInAnonymously
- signInWithEmailAndPassword
- signInWithCredential
- signInWithCustomToken
rxFirebaseAuth.signInAnonymously(FirebaseAuth.getInstance())
.subscribe(new Action1<AuthResult>() {
@Override
public void call(AuthResult authResult) {
// process with authResult
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
// process auth error
}
});
Database:
You can query single value like:
rxFirebaseDatabase.observeSingleValue(firebase.child("users").child("nick"), User.class)
.subscribe(new Action1<User>() {
@Override
public void call(User user) {
// process User value
}
});
or the list of values:
rxFirebaseDatabase.observeValuesList(firebase.child("posts"), BlogPost.class)
.subscribe(new Action1<List<BlogPost>>() {
@Override
public void call(List<BlogPost> blogPosts) {
// process blogPosts collection
}
});
Download
Gradle:
dependencies {
compile 'com.google.firebase:firebase-auth:9.0.0'
compile 'com.google.firebase:firebase-database:9.0.0'
compile 'com.kelvinapps:rxfirebase:0.0.6'
}
Maven:
<dependency>
<groupId>com.kelvinapps</groupId>
<artifactId>rxfirebase</artifactId>
<version>0.0.6</version>
<type>pom</type>
</dependency>
No comments:
Post a Comment