[Unity] ContinueWith never fires first time getting data using GetValueAsync

921 views
Skip to first unread message

Johan Gustafsson

unread,
Nov 18, 2016, 9:13:52 AM11/18/16
to Firebase Google Group
I'm using the new Unity-SDK to implement a highscore feature in a game.

I am using the code below to fetch update the highscores but the first time I call it the ContinueWith does not fire. However, after the first call it starts working just fine. What am I doing wrong here?

    public void GetHighscore(Action<DataSnapshot> callback) {
        highscoreRef.OrderByChild("total_score").LimitToLast(10).GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted) {
                // Handle the error...
                Debug.Log(task.Exception.Message);
            }
            else if (task.IsCompleted) {
                callback(task.Result);
            }
        });
    }

So the first time it never enters the lambda function inside ContinueWith.


Best regards,
Johan

Frank van Puffelen

unread,
Nov 18, 2016, 9:15:18 AM11/18/16
to Firebase Google Group

Kato Richardson

unread,
Nov 18, 2016, 3:31:49 PM11/18/16
to Firebase Google Group

Hi Johan,

Are there no possible cases other than error or isCompleted? Can you add an else to check?

I'm not a unity buff, but that seems like the first thing to rule out.

Kato


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/eb77e83a-80ff-4030-a9f6-434f09660152%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benjamin Wulfe

unread,
Nov 18, 2016, 5:18:08 PM11/18/16
to Firebase Google Group
Hi Johan, I am not seeing what you are seeing.  I would double check that you are handling cases where say the Result might be null or empty in your callback.
Our support folks are good at walking through issues with you.

Johan Gustafsson

unread,
Nov 19, 2016, 2:06:03 PM11/19/16
to Firebase Google Group

Johan Gustafsson

unread,
Nov 19, 2016, 2:06:03 PM11/19/16
to Firebase Google Group
Hey Kato,

It never enters the lambda function so the code inside doesnt really matter. Benjamin and I had a discussion regarding this in http://stackoverflow.com/questions/40679118/new-firebase-unity-sdk-calling-getvalueasync-on-a-query-wont-fire-its-continue/ if you are interested.


Best regards


Den fredag 18 november 2016 kl. 21:31:49 UTC+1 skrev Kato Richardson:

Hi Johan,

Are there no possible cases other than error or isCompleted? Can you add an else to check?

I'm not a unity buff, but that seems like the first thing to rule out.

Kato

On Nov 18, 2016 6:13 AM, "Johan Gustafsson" <johan....@gmail.com> wrote:
I'm using the new Unity-SDK to implement a highscore feature in a game.

I am using the code below to fetch update the highscores but the first time I call it the ContinueWith does not fire. However, after the first call it starts working just fine. What am I doing wrong here?

    public void GetHighscore(Action<DataSnapshot> callback) {
        highscoreRef.OrderByChild("total_score").LimitToLast(10).GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted) {
                // Handle the error...
                Debug.Log(task.Exception.Message);
            }
            else if (task.IsCompleted) {
                callback(task.Result);
            }
        });
    }

So the first time it never enters the lambda function inside ContinueWith.


Best regards,
Johan

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Kato Richardson

unread,
Nov 21, 2016, 12:58:25 PM11/21/16
to Firebase Google Group
Cool, glad you got a solution. As a general rule of etiquette, you can show respect for the community's time by always letting developers know when you cross-post your questions. In this way, you can avoid multiple developers spending precious time typing out duplicate follow-up questions and replies.

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages