Coder Social home page Coder Social logo

rxfirebase's People

Contributors

ahaverty avatar nmoskalenko avatar ordonteam avatar renanferrari 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  avatar

rxfirebase's Issues

onError while using GenericTypeIndicator

Getting error while fetching records using GenericTypeIndicator, it was working in the first try.

Error : java.lang.RuntimeException: com.kelvinapps.rxfirebase.exceptions.RxFirebaseDataCastException: unable to cast firebase data response to generic type

Using the very same code in another class and its working there. Same code copy pasted from here itself.

`RxFirebaseDatabase.observeValueEvent(databaseReference,
DataSnapshotMapper.of(new GenericTypeIndicator<HashMap<String, Vehicle>>() {
}))
.subscribe(new Subscriber<HashMap<String, Vehicle>>() {
@OverRide
public void onCompleted() {
Logger.log(TAG, "onCompleted: ");
}

                @Override
                public void onError(Throwable e) {
                    Logger.log(TAG, "onError: " + e);
                   // Here I'm getting this
                  // java.lang.RuntimeException: com.kelvinapps.rxfirebase.exceptions.RxFirebaseDataCastException: unable to cast firebase data response to generic type
                }

                @Override
                public void onNext(HashMap<String, Vehicle> vehicles) {

                }`

how can i get all key of DatabaseSnapshot

HI Nick,
I have a Database Tree bellow and need to get all child Key of mdQXSbGGrLb7hblbUF1ME3DgM323 ,
( list of Longs 1525626000000,1525712400000,1525798800000,1525885200000,1525971600000).
How can I do it?
Thanks Nick!

-Income
	--mdQXSbGGrLb7hblbUF1ME3DgM323
		---1525626000000
			----LBvD1oN1jXCvwNeYFj_: 601110
			----LByog73CligakaBsmxQ: 20200
			----LDvRldeuade3_323: 9999
		---1525712400000
			----LBvD1oN1jXCvwNeYFj_: 1232
			----LDLTKsWDBMcE3NrRQOE: 36000
		---1525798800000
			----LDLTKsWDBMcE3NrRQOE: 18000
		---1525885200000
			----LDLTKsWDBMcE3NrRQOE: 546000
		---1525971600000
			----LDLTKsWDBMcE3NrRQOE: 30000
			----LByog73CligakaBsmxQ: 22200
		

Error while importing project

Want to add some stuff but when importing and building the project I'm getting this build error:

image

`Error:(26, 28) No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').``

Any clues about this?

Continous observing

Am I wrong in asking why all of the other listeners aren't like @renanferrari 's pull request #3, allowing continuous listening like Firebase intended?
Or am I using these incorrectly?

Add toList get bug

If I added toList onNext or else never call.
This work correct

RxFirebaseDatabase.observeChildEvent(reference.orderByChild("dateMs").startAt(start.getTimeInMillis()).endAt(end.getTimeInMillis()))
                .map(dataSnapshotRxFirebaseChildEvent -> {
                    return dataSnapshotRxFirebaseChildEvent.getValue().getValue(FirebaseBlowResult.class);
                })
                .compose(RxUtils.applySchedulers())
                .subscribe();

Add toList and get bug

RxFirebaseDatabase.observeChildEvent(reference.orderByChild("dateMs").startAt(start.getTimeInMillis()).endAt(end.getTimeInMillis()))
                .map(dataSnapshotRxFirebaseChildEvent -> {
                    return dataSnapshotRxFirebaseChildEvent.getValue().getValue(FirebaseBlowResult.class);
                })
                .toList()
                .compose(RxUtils.applySchedulers())
                .subscribe();

subscriber never call

Asynchronous retrieval help

This isn't particularly an issue with RxFirebase but I'm wondering if its currently possible. @renanferrari perhaps you may be able to answer this also?

In some cases I want to asynchronously return a value. I've tried a fair few suggestions on RxJava forums including stuff like:

User user = RxFirebaseDatabase.observeSingleValue(
    reference.child("users").child("nick"), User.class).toBlocking().single();

But haven't had any luck.
Have you any suggestions on how to do so, or even synchronously wait for multiple observers, so as to avoid long chains of the following:

// My current anti-pattern
#
call1.subscribe(
    call2.subscribe(
        call3.subscribe(
            //Now do something with all 3 pieces of data
        )
    )
)

Thank you

Change thread

Hi @nmoskalenko and all contributors, thanks for this handy library, I was looking for something like that.

My main issue working with Firebase is that the return calls are always in the main thread, unless you do this workaround using a thread executor (https://firebase.googleblog.com/2016/10/become-a-firebase-taskmaster-part-4.html, see all the parts)

So my point is, is there a way to use your library an use the threads defined in a subscription of Rx instead of returning to the main thread?

Thanks!

Returning datasnapshot keys from children event listener

I'm not sure about everyone else but I personally use datasnapshot keys (.getKey()) quite a bit, especially on child listeners. Below shows an example of what I currently have adapted things to locally. I'd make a pull request but I'd imagine a change like this would mess with existing code if anyone were to upgrade.
What do you suggest? Would anyone else make use of this? I guess one solution is to duplicate every method
E.G:

observeChildrenEvents(query, clazz);
//Stays as is

observeChildrenEventsWithKey(query, clazz);
//Returns the datasnapshot's key also

It seems like a horrible workaround though. Or would something like this be better?:

observeChildrenEvents(query, clazz);
//Stays as is

observeChildrenEvents(query, clazz, boolean returnKey);
//Returns the datasnapshot's key also

Atleast this way, the code could be encapsulated, and wouldn't effect anyone upgrading?

Partial example of what was, and what I now have:

Current:

@Override
public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) {
    if (!subscriber.isUnsubscribed()) {
        subscriber.onNext(
            new RxFirebaseChildEvent<T>(dataSnapshot.getValue(clazz),
            previousChildName,
            RxFirebaseChildEvent.EventType.ADDED));
    }
}

Proposition:

@Override
public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) {
    if (!subscriber.isUnsubscribed()) {
        subscriber.onNext(
            new RxFirebaseChildEvent<T>(dataSnapshot.getValue(clazz),
            dataSnapshot.getKey(), //<- Notice returning key also
            previousChildName,
            RxFirebaseChildEvent.EventType.ADDED));
    }
}

Java Server Version

I've adapted your repository locally to work for Firebase Java Server (https://firebase.google.com/docs/server/setup)

When I say adapted, I've taken the core of your RxFirebaseDatabase and RxFirebaseChildEvent classes and essentially dropped them into a new project, removing any trace of android, also adding the above firebase server dependency from Google.

I want to share it similarly to this great repo, for anyone using Firebase server.
What would you recommend? It'd be great to be able to link the core functionality of this repo's RxDatabase, but I'm guessing a new repo would be best? Should I just upload my own, gradle it up, and maybe ask you to add a link to it in your readme?

Thanks again for making Firebase so much more usable!

RxFirebaseStorage.putFile onError but no error

I got an error while using RxFirebaseStorage.putFile(storageReference, uri)
on version 0.0.14 of this lib and
using 'com.google.firebase:firebase-storage:9.4.0'

onError:
java.lang.UnsupportedOperationException: addOnCompleteListener is not implemented
at com.google.android.gms.tasks.Task.addOnCompleteListener(Unknown Source)
at com.kelvinapps.rxfirebase.RxHandler.assignOnTask(RxHandler.java:27)
at com.kelvinapps.rxfirebase.RxFirebaseStorage$10.call(RxFirebaseStorage.java:127)
at com.kelvinapps.rxfirebase.RxFirebaseStorage$10.call(RxFirebaseStorage.java:124)
at rx.Observable.subscribe(Observable.java:10246)
at rx.Observable.subscribe(Observable.java:10213)

Even though the image was correctly uploaded.

Switch to a non-static API

It would help our testing if there was a non-static API - it would allow mock instances of the RxFirebase* classes to be injected with Dagger while we are testing.

Observe on null-value causes onError

When observing with e.g.: observeValue and the observed value is null - onError is called.
Thus a route which doesn't exist at the moment of the subscription cannot be observed anymore - which should not be the case in my opinion.

This behavior is the same for all observe operators.

Support for RxJava 2.x

Currently RxJava 2.0.0 was released.
https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0
Are there plans for RxFirebase implement it?
I believe decision should be made if it should be continued on a separate branch in this repo or forked into separate one?

I looked briefly into it and RxFirebaseDatabase using nulls looks like the hardest problem to resolve. RxJava 2 does not allow nulls into stream and DataSnapshotMapper's behavior is to just return null if there in no value at given node.
There are few options:

  • We could drop support for functions taking Class parameter or mapper function but I find them very handy.
  • We could introduce some wrapper around returned data but then we would have to unwrap data every time
  • We could just call onError when there is no such node but then error becomes ambiguous. Observer doesn't know it error was caused by null value or firebase calling one of onCancelled methods
    com.google.firebase.database.ValueEventListener#onCancelled(DatabaseError error)
    com.google.firebase.database.ChildEventListener#onCancelled(DatabaseError error)
    This answer suggests that onCancelled shouldn't be a reason to error and unregister from listener.

This is quite easy to resolve in case of observeSingleValueEvent as we should just return empty stream but for persisting listeners I am quite at loss here and could use some help.

Also, I think non single value database queries should use Flowable type that guarantees that backpressure is handled and provide default backpressure strategy, rules for backpressure handling can always be changed downstream.

As for single value database queries we could use Single or Maybe type.

What about proguard?

What about proguard?
Error is:
Warning: com.kelvinapps.rxfirebase.RxFirebaseUser$6: can't find referenced class com.google.firebase.auth.FirebaseUser

linkWithCredential doesn't seem to work

After using RxFirebaseUser.linkWithCredetial for facebook token Firebase Console in the web doesn't show a user with facebook connected.
Second attempt to link already linked user doesn't result in an exception that is know to be thrown by firebase in that case

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.