Giter Site home page Giter Site logo

kunny / rxfirebase Goto Github PK

View Code? Open in Web Editor NEW
139.0 9.0 25.0 515 KB

RxJava binding APIs for Firebase.

License: Apache License 2.0

XSLT 2.09% Kotlin 60.07% Java 37.84%
kotlin firebase firebase-realtime-database firebase-sdk firebase-authentication rxjava android android-library

rxfirebase's Introduction

RxFirebase

CircleCI codecov Android Arsenal

RxJava binding APIs for Firebase Android SDK.

Modules

firebase-auth

Maven Central

RxJava binding APIs for Firebase Authentication Android SDK.

// firebase-auth
implementation 'com.androidhuman.rxfirebase2:firebase-auth:16.1.0.0'
implementation 'com.google.firebase:firebase-auth:16.1.0'

// required dependency: firebase-core
implementation 'com.androidhuman.rxfirebase2:firebase-core:16.0.5.0'
implementation 'com.google.firebase:firebase-core:16.0.5'

// required dependency: rxjava2
implementation 'io.reactivex.rxjava2:rxjava:2.1.8'

firebase-auth-kotlin

Maven Central

Kotlin support module for firebase-auth.

// firebase-auth
implementation 'com.androidhuman.rxfirebase2:firebase-auth-kotlin:16.1.0.0'
implementation 'com.androidhuman.rxfirebase2:firebase-auth:16.1.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.4'

// required dependency: firebase-core
implementation 'com.androidhuman.rxfirebase2:firebase-core:16.0.5.0'
implementation 'com.google.firebase:firebase-core:16.0.5'

// required dependency: rxjava2
implementation 'io.reactivex.rxjava2:rxjava:2.1.8'

firebase-database

Maven Central

RxJava binding APIs for Firebase Realtime Database Android SDK.

// firebase-database
implementation 'com.androidhuman.rxfirebase2:firebase-database:16.0.3.0'
implementation 'com.google.firebase:firebase-database:16.0.3'

// required dependency: firebase-core
implementation 'com.androidhuman.rxfirebase2:firebase-core:16.0.5.0'
implementation 'com.google.firebase:firebase-core:16.0.5'

// required dependency: rxjava2
implementation 'io.reactivex.rxjava2:rxjava:2.1.8'

firebase-database-kotlin

Maven Central

Kotlin support module for firebase-database

// firebase-database
implementation 'com.androidhuman.rxfirebase2:firebase-database-kotlin:16.0.3.0'
implementation 'com.androidhuman.rxfirebase2:firebase-database:16.0.3.0'
implementation 'com.google.firebase:firebase-database:16.0.3'

// required dependency: firebase-core
implementation 'com.androidhuman.rxfirebase2:firebase-core:16.0.5.0'
implementation 'com.google.firebase:firebase-core:16.0.5'

// required dependency: rxjava2
implementation 'io.reactivex.rxjava2:rxjava:2.1.8'

firebase-firestore

Maven Central

RxJava binding APIs for Firebase Firestore Android SDK.

// firebase-firestore
implementation 'com.androidhuman.rxfirebase2:firebase-firestore:17.1.5.0'
implementation 'com.google.firebase:firebase-firestore:17.1.5'

// required dependency: firebase-core
implementation 'com.androidhuman.rxfirebase2:firebase-core:16.0.5.0'
implementation 'com.google.firebase:firebase-core:16.0.5'

// required dependency: rxjava2
implementation 'io.reactivex.rxjava2:rxjava:2.1.8'

firebase-firestore-kotlin

Maven Central

Kotlin support module for firebase-firestore.

// firebase-firestore
implementation 'com.androidhuman.rxfirebase2:firebase-firestore-kotlin:17.1.5.0'
implementation 'com.androidhuman.rxfirebase2:firebase-firestore:17.1.5.0'
implementation 'com.google.firebase:firebase-firestore:17.1.5'

// required dependency: firebase-core
implementation 'com.androidhuman.rxfirebase2:firebase-core:16.0.5.0'
implementation 'com.google.firebase:firebase-core:16.0.5'

// required dependency: rxjava2
implementation 'io.reactivex.rxjava2:rxjava:2.1.8'

firebase-storage (Coming soon!)

Maven Central

RxJava binding APIs for Firebase Storage Android SDK.

// firebase-storage
implementation 'com.androidhuman.rxfirebase2:firebase-storage:16.0.1.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'

// required dependency: firebase-core
implementation 'com.androidhuman.rxfirebase2:firebase-core:16.0.5.0'
implementation 'com.google.firebase:firebase-core:16.0.5'

// required dependency: rxjava2
implementation 'io.reactivex.rxjava2:rxjava:2.1.8'

firebase-storage-kotlin (Coming soon!)

Maven Central

Kotlin support module for firebase-storage.

// firebase-storage
implementation 'com.androidhuman.rxfirebase2:firebase-storage-kotlin:16.0.1.0'
implementation 'com.androidhuman.rxfirebase2:firebase-storage:16.0.1.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'

// required dependency: firebase-core
implementation 'com.androidhuman.rxfirebase2:firebase-core:16.0.5.0'
implementation 'com.google.firebase:firebase-core:16.0.5'

// required dependency: rxjava2
implementation 'io.reactivex.rxjava2:rxjava:2.1.8'

Kotlin extension modules

Each kotlin support module maps all methods in Java module into an extension function on following classes:

Basically, extension function has same name of methods in RxXXX classes in Java module.

If extension function conflicts with a method in a class that is being extended, it will be renamed with rx prefix.

For more details, please refer to following 'Usage' section.

Usage

See official documentation for the details.

Versioning

RxFirebase uses a versioning rule that is related to corresponding Firebase's version by following rule:

RxFirebaseVersion : {major}.{minor}.{patch1}.{patch2} =
    {Firebase major}.{Firebase minor}.{Firebase patch}.{RxFirebase patch}

For example, a library version that depends on 10.2.0 version of Firebase SDK, whose patch version is 1 will be 10.2.0.1.

License

Copyright 2016-2018 Taeho Kim <[email protected]>

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.

rxfirebase's People

Contributors

b3er avatar kunny avatar tallnato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxfirebase's Issues

Update README.md requires jitpack.io

The transitive dependency retro-optional can only be found in the jitpack.io repository. That means jitpack.io is also requirment for RxFirebase. It would help to add that info to your README.md, similar to the "Get It" section on retro-optional
Example:

 repositories {
        // ...
        maven { url "https://jitpack.io" }
  }

Error on sign out: IllegalStateException: onSubscribe not called in proper order

How to reproduce:
Add the following line to the signOut() test in RxFirebaseAuthTest.kt:938: assertNoErrors() and run the test.
Result:

java.lang.AssertionError: Error(s) present: [java.lang.IllegalStateException: onSubscribe not called in proper order] (latch = 0, values = 0, errors = 1, completions = 1)

	at io.reactivex.observers.BaseTestConsumer.fail(BaseTestConsumer.java:191)
	at io.reactivex.observers.BaseTestConsumer.assertNoErrors(BaseTestConsumer.java:276)
	at com.androidhuman.rxfirebase2.auth.RxFirebaseAuthTest.signOut(RxFirebaseAuthTest.kt:938)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalStateException: onSubscribe not called in proper order
	at io.reactivex.observers.TestObserver.onComplete(TestObserver.java:187)
	at com.androidhuman.rxfirebase2.auth.SignOutObserver.subscribeActual(SignOutObserver.java:19)
	at io.reactivex.Completable.subscribe(Completable.java:1741)
	at com.androidhuman.rxfirebase2.auth.RxFirebaseAuthTest.signOut(RxFirebaseAuthTest.kt:933)
	... 23 more


Process finished with exit code 255

Update Readme with RxJava version

This seems to be using RxJava 1.x. Update the Readme to reflect this because RxJava 2 is out and this lacks compatibility with it (observeOn for example).

Logo Design: RxFirebase

Hello!

I'm a graphic designer and I like to support open source projects. I would like to design a logo for your project if you interested, I will be happy to work with you! :)

Best Regards

Baran Pirinçal

Graphic Designer

Update to 11.0.2

Hi, when can you release a version with an update to version 11.0.2?

Thanks

Consider a Children Ready Event

It's tough to show empty states and handle other ui logic when you use Firebase's ChildEventListener as is. I like to add a value event listener which fires after all your current data has been loaded. Something like this:

public static Observable<FirebaseChildEvent> children(Query query) {
        return Observable.fromEmitter(new Action1<AsyncEmitter<FirebaseChildEvent>>() {
            @Override public void call(AsyncEmitter<FirebaseChildEvent> emitter) {
                ChildEventListener listener = new ChildEventListener() {
                    @Override public void onChildAdded(DataSnapshot dataSnapshot, String previousKey) {
                        emitter.onNext(create(dataSnapshot, ADDED, previousKey));
                    }

                    @Override public void onChildChanged(DataSnapshot dataSnapshot, String previousKey) {
                        emitter.onNext(create(dataSnapshot, CHANGED, previousKey));
                    }

                    @Override public void onChildRemoved(DataSnapshot dataSnapshot) {
                        emitter.onNext(create(dataSnapshot, REMOVED, null));
                    }

                    @Override public void onChildMoved(DataSnapshot dataSnapshot, String previousKey) {
                        emitter.onNext(create(dataSnapshot, MOVED, previousKey));
                    }

                    @Override public void onCancelled(DatabaseError databaseError) {
                        emitter.onError(databaseError.toException());
                    }
                };
                ValueEventListener readyListener = new ValueEventListener() {
                    @Override public void onDataChange(DataSnapshot dataSnapshot) {
                        emitter.onNext(create(dataSnapshot, READY, null));
                    }

                    @Override public void onCancelled(DatabaseError databaseError) {
                        emitter.onError(databaseError.toException());
                    }
                };
                emitter.setCancellation(new AsyncEmitter.Cancellable() {
                    @Override public void cancel() throws Exception {
                        query.removeEventListener(listener);
                        query.removeEventListener(readyListener);
                    }
                });
                query.addChildEventListener(listener);
                query.addListenerForSingleValueEvent(readyListener);
            }
        }, AsyncEmitter.BackpressureMode.BUFFER);
    }

Firebase's internal optimisation makes sure that the data on your reference only comes through the wire once.

Unable to resolve TaskResult if 'transitive=false'

This file will be unavailable com.androidhuman.rxfirebase.common.model.TaskResult. Browsed my project's dependency library and indeed, it wasn't there.

Removing 'transitive = false' seems to resolve it. What's the reason behind the flag anyway?

How to diferences different types of errors

I need to diferences between different DatabaseException errors, when going from DatabaseError to DatabaseException the information regarding the error is lost, maybe the solution would be an inheritance of DatabaseException to wrap the DatabaseError object

i cannot download lib from maven

after adding artifact to the build.gradle it failed to sync the project and show this error
Searched in the following locations:
file:/D:/Android/android-sdk/extras/m2repository/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/firebase-d
atabase-kotlin-11.8.0.1.pom
file:/D:/Android/android-sdk/extras/m2repository/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/firebase-d
atabase-kotlin-11.8.0.1.jar
file:/D:/Android/android-sdk/extras/google/m2repository/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/fir
ebase-database-kotlin-11.8.0.1.pom
file:/D:/Android/android-sdk/extras/google/m2repository/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/fir
ebase-database-kotlin-11.8.0.1.jar
file:/D:/Android/android-sdk/extras/android/m2repository/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/fi
rebase-database-kotlin-11.8.0.1.pom
file:/D:/Android/android-sdk/extras/android/m2repository/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/fi
rebase-database-kotlin-11.8.0.1.jar
https://dl.google.com/dl/android/maven2/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/firebase-database-k
otlin-11.8.0.1.pom
https://dl.google.com/dl/android/maven2/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/firebase-database-k
otlin-11.8.0.1.jar
https://jcenter.bintray.com/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/firebase-database-kotlin-11.8.0
.1.pom
https://jcenter.bintray.com/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/firebase-database-kotlin-11.8.0
.1.jar
https://oss.sonatype.org/content/repositories/snapshots/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/fir
ebase-database-kotlin-11.8.0.1.pom
https://oss.sonatype.org/content/repositories/snapshots/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/fir
ebase-database-kotlin-11.8.0.1.jar
https://repo1.maven.org/maven2/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/firebase-database-kotlin-11.
8.0.1.pom
https://repo1.maven.org/maven2/com/androidhuman/rxfirebase2/firebase-database-kotlin/11.8.0.1/firebase-database-kotlin-11.
8.0.1.jar

Release new versions

RxFirebase version Firebase version Change(s)
10.2.1.0 10.2.1 SDK update
10.2.4.0 10.2.4 SDK update

Query does not work

Sample code:

               final Query query = db.getReference(MESSAGES)
                        .orderByChild(MESSAGES__CONVERSATION_KEY)
                        .equalTo(defaultDialog.getId())
                        .limitToLast(1);

                final Observable<DataSnapshot> messageObservable
                        = RxFirebaseDatabase.data(
                        query.getRef());

                messageObservable.subscribe(dataSnapshot -> {
                    logger.logd(TAG, "RX value listener message count: " + dataSnapshot.getChildrenCount());
                });

                query.addListenerForSingleValueEvent(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {
                        logger.logd(TAG, "Non-RX value listener message count: " + dataSnapshot.getChildrenCount());
                    }

                    @Override
                    public void onCancelled(DatabaseError databaseError) {

                    }
                });

The value I get for RX and non-RX is different. The observable version is not applying any of the query criteria.

Update: after a bit of digging, I discovered that the problem lies with the fact that the listeners in DataOnSubscribe needs to be attached to a Query object, not a DatabaseReference.

Why use ObservableOnSubscribe instead of extends Observable itself

ObservableOnSubscribe is used in Observable.create() method and will do that cancelation check for your inside of it. So it's redundant to use ObservableOnSubscribe IMO. I propose to directly use Observable as super class and it can reduce allocations compare to Observable.create() : ObservableCreate + ObservableOnSubscribe + Emitter -> CustomObservable. But it's sure a big change for this code base. Do you interested in this approach ? Or you prefer using ObservableOnSubscribe in some particular reason?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.