All Projects → FrangSierra → Rxfirebase

FrangSierra / Rxfirebase

Licence: mit
Rxjava 2.0 wrapper on Google's Android Firebase library.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxfirebase

Laravel Firebase
A Laravel package for the Firebase PHP Admin SDK
Stars: ✭ 369 (-27.5%)
Mutual labels:  firebase, firebase-database, firebase-storage, firebase-realtime-database, firebase-cloud-messaging, firebase-auth, firebase-authentication
Chatter
Real time chat app written in Swift 4 using Firebase
Stars: ✭ 30 (-94.11%)
Mutual labels:  firebase-cloud-messaging, firebase-auth, firebase-database, firebase-storage, firebase-realtime-database, firebase-authentication, firebase-functions
Firebase Js Sdk
Firebase Javascript SDK
Stars: ✭ 3,844 (+655.21%)
Mutual labels:  firebase, firebase-database, firebase-storage, firebase-realtime-database, firebase-cloud-messaging, firebase-auth, firebase-authentication
Internalappstore
📦 Manage your own internal Android App Store.
Stars: ✭ 295 (-42.04%)
Mutual labels:  firebase-functions, firebase, firebase-database, firebase-storage, firebase-cloud-messaging, firebase-auth
React Firebase Hooks
React Hooks for Firebase.
Stars: ✭ 2,227 (+337.52%)
Mutual labels:  firebase, firebase-database, firebase-storage, firebase-realtime-database, firebase-auth, firebase-authentication
Combinefirebase
Combine wrapper on Google's iOS Firebase library.
Stars: ✭ 126 (-75.25%)
Mutual labels:  firebase-functions, database, firebase, storage, firebase-storage, firebase-realtime-database
Firebase Php
Unofficial Firebase Admin SDK for PHP
Stars: ✭ 1,657 (+225.54%)
Mutual labels:  firebase, firebase-database, firebase-storage, firebase-cloud-messaging, firebase-auth, firebase-authentication
Whatsup
**Deprecated** Real time chat app written in Swift 4 using Firebase and OTP Authentication
Stars: ✭ 39 (-92.34%)
Mutual labels:  firebase, firebase-database, firebase-storage, firebase-realtime-database, firebase-cloud-messaging, firebase-authentication
firebase-bundle
A Symfony Bundle for the Firebase PHP Admin SDK
Stars: ✭ 112 (-78%)
Mutual labels:  firebase-cloud-messaging, firebase-auth, firebase-database, firebase-storage, firebase-authentication
uMe
Online Chatting Application (Android) || Messaging App || Firebase
Stars: ✭ 138 (-72.89%)
Mutual labels:  firebase-cloud-messaging, firebase-auth, firebase-database, firebase-storage, firebase-realtime-database
The Road To React With Firebase
📓The Road to React with Firebase: Your journey to build business applications with React and Firebase.
Stars: ✭ 82 (-83.89%)
Mutual labels:  firebase, firebase-database, firebase-realtime-database, firebase-auth, firebase-authentication
Quickstart Cpp
Firebase Quickstart Samples for C++
Stars: ✭ 123 (-75.83%)
Mutual labels:  firebase, firebase-database, firebase-storage, firebase-cloud-messaging, firebase-auth
Firebase Mock
Firebase mock library for writing unit tests
Stars: ✭ 319 (-37.33%)
Mutual labels:  firebase-functions, firebase, firebase-database, firebase-storage, firebase-auth
Firebase Android Sdk
Firebase Android SDK
Stars: ✭ 1,704 (+234.77%)
Mutual labels:  firebase-functions, firebase, firebase-database, firebase-storage, firebase-realtime-database
Chatapp
Chat App with all functionality private chat, contacts, friends request, find friends,for profile settings image cropper functionality, settings, logout also send text, image and all type of files, delete your files for you and everyone , login with email and mobile number and real time database firebase and for notification purpose Node Js used.
Stars: ✭ 25 (-95.09%)
Mutual labels:  firebase-functions, firebase, firebase-database, firebase-realtime-database, firebase-cloud-messaging
FirebaseChatApp
A Chat app built on firebase features such as firebase-ui,database,storage and cloud messaging
Stars: ✭ 20 (-96.07%)
Mutual labels:  firebase-cloud-messaging, firebase-auth, firebase-database, firebase-storage, firebase-realtime-database
firebase
Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
Stars: ✭ 36 (-92.93%)
Mutual labels:  firebase-auth, firebase-database, firebase-storage, firebase-realtime-database, firebase-functions
Firebase Admin Node
Firebase Admin Node.js SDK
Stars: ✭ 1,050 (+106.29%)
Mutual labels:  firebase, firebase-database, firebase-cloud-messaging, firebase-auth, firebase-authentication
Firebase Ios Sdk
Firebase iOS SDK
Stars: ✭ 3,309 (+550.1%)
Mutual labels:  firebase, firebase-database, firebase-storage, firebase-auth, firebase-authentication
Hify
Social network powered by firebase
Stars: ✭ 115 (-77.41%)
Mutual labels:  firebase-functions, firebase, firebase-storage, firebase-cloud-messaging, firebase-authentication

Rx2Firebase

Rxjava 2.0 wrapper on Google's Android Firebase library.

This repository started as a personal usage of Nick Moskalenko RxFirebase library. You can check his work here.

Download

Gradle:
dependencies {
  compile 'com.github.FrangSierra:RxFirebase:1.5.6'
}
allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}

Usage

Library provides set of static methods of classes:

  • RxFirebaseAuth
  • RxFirebaseUser
  • RxFirebaseDatabase
  • RxFirebaseStorage
  • RxFirestore
  • RxFirebaseFunctions

Authentication:

Sign in with email and password:

    RxFirebaseAuth.signInWithEmailAndPassword(auth, email, password)
                .map(authResult -> authResult.getUser() != null)
                .take(1)
                .subscribe(logged -> {
                    Log.i("Rxfirebase2", "User logged " + logged);
                });

Firestore:

You can observe values providing the Class of expected data like:

    DocumentReference document = firestore.collection("Users").document("UserId_1");
    RxFirestore.observeDocumentRef(document)
       .subscribe( userDoc -> {
          //Do something with my snapshot
       });

Get and set documents on a specific reference:

    DocumentReference document = firestore.collection("Users").document("UserId_1");
    User mynewUser = User("newUserName", 24);
    //Set data
    RxFirestore.setDocument(document, myNewUser).subscribe();
    //Get and map data
    RxFirestore.getDocument(document)
       .map( userDoc -> { return userDoc.toObject(User.class); })
       .subscribe( casterUser -> {
          //Do something with my already casted user
       });

Finally you can do sync operations on the database using runTransaction and if you wanna realize multiple operations at once, you should use the method atomicOperation which wraps the WriteBatch related methods from Firestore.

Database:

You can observe values providing the Class of expected data like:

    RxFirebaseDatabase.observeSingleValueEvent(getPostsRef().child("posts"), Post.class)
                .subscribe(post -> {
           //Do something with yourpost 
        });

or providing your own mapper between DataSnapshot and your data type:

    RxFirebaseDatabase.observeSingleValueEvent(getPostsRef().child("posts"),
                dataSnapshot -> {
                    // do your own mapping here
                    return new Author();
                })
                .subscribe(author -> {
                    // process author value
                });

There are some pre-defined mappers to make things easier:

Observing list values
    RxFirebaseDatabase.observeSingleValueEvent(getPostsRef().child("posts"), DataSnapshotMapper.listOf(PostComment.class))
                .subscribe(blogPost -> {
                    // process postcomment list item
                });
Observing map values
     RxFirebaseDatabase.observeSingleValueEvent(getPostsRef().child("posts"), DataSnapshotMapper.mapOf(PostComment.class))
                .subscribe(PostCommentAsMapItem -> {
                    // process blogPost as key-value pair
                });

Storage:

Download file from Firebase storage

    RxFirebaseStorage.getFile(getStorageRef(), targetFile)
                .subscribe(taskSnapshot -> {
                    Log.i("RxFirebaseSample", "transferred: " + snapshot.getBytesTransferred() + " bytes");
                }, throwable -> {
                    Log.e("RxFirebaseSample", throwable.toString());
            });

or download file as bytes array

    RxFirebaseStorage.getBytes(getStorageRef(), 1024 * 100)
                .subscribe(bytes -> {
                    Log.i("RxFirebaseSample", "downloaded: " + new String(bytes));
                }, throwable -> {
                    Log.e("RxFirebaseSample", throwable.toString());
            });

RxFirebaseQuery

RxFirebaseQuery is a builder class used to work together with methods from RxFirebaseDatabase that allow you to retrieve data from multiple databaseReferences. Doing this allow you to build and create dynamic queries to retrieve database objects from references retrieved from different tables easily. At the moment RxFirebaseQuery just allow the user to create the queries and retrieve the data. Filters should be done with the DatabaseReference items that you pass to the constructor. In other hand for update and delete data you should use Firebase method updateChildren()

	DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
		      DatabaseReference from = reference.child("tweets");
		      Query where = reference.child("users").child(userId).child("feedReferences");
		      RxFirebaseQuery.getInstance()
			    .filterByRefs(from, where)
			    .asList()
			    .subscribe(dataSnapshots -> {
			       Log.i("RxFirebase", "Retrieved a total of " + dataSnapshots.size() + " tweets");
			       for (DataSnapshot dataSnapshot : dataSnapshots) {
				  Tweet tweet = dataSnapshot.getValue(Tweet.class);
				  Log.i("RxFirebase", "New tweet for user feed: " + tweet.getDescription());
			       }
			    });

## RxJava and RxJava 2.0
One of the differences between RxJava and RxJava 2 is that RxJava 2 no longer accepts `null` values. Throwing a `NullPointerException` immediately. For this reason some of the methods of the library as been redesigned to return a `Completable` instead of a `Observable<Void>`. For example:

#### RxFirebase

```java
@NonNull
public static Observable<Void> updateEmail(@NonNull final FirebaseUser firebaseUser, @NonNull final String email) {
        return Observable.create(new Observable.OnSubscribe<Void>() {
            @Override
            public void call(final Subscriber<? super Void> subscriber) {
                RxHandler.assignOnTask(subscriber, firebaseUser.updateEmail(email));
            }
        });
}

Rx2Firebase

@NonNull
public static Completable updateEmail(@NonNull final FirebaseUser firebaseUser, @NonNull final String email) {
        return Completable.create(new CompletableOnSubscribe() {
            @Override
            public void subscribe(CompletableEmitter emitter) throws Exception {
                RxCompletableHandler.assignOnTask(emitter, firebaseUser.updateEmail(email));
            }
        });
}

RxCompletableHandler manages the CompletableEmitters in the same way that RxHandler manages the Subscriber. You can check all the differences between RxJava and RxJava 2.0 in the next Link

License

MIT License

Copyright (c) 2016 Francisco García Sierra

Permission is hereby granted, free of charge, to any person obtaining a 
copy of this software and associated documentation files (the "Software"), 
to deal in the Software without restriction, including without limitation 
the rights to use, copy, modify, merge, publish, distribute, sublicense, 
and/or sell copies of the Software, and to permit persons to whom the 
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included 
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
OTHER DEALINGS IN THE SOFTWARE.

Support on Beerpay

Hey dude! Help me out for a couple of 🍻!

Beerpay Beerpay

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].