Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observable cannot cast Expected #324

Open
TomasGranda opened this issue Aug 5, 2024 · 1 comment
Open

Observable cannot cast Expected #324

TomasGranda opened this issue Aug 5, 2024 · 1 comment

Comments

@TomasGranda
Copy link

TomasGranda commented Aug 5, 2024

Hi, i'm trying to use the Observer this way:

var observable = GetFirebaseClient()
      .Child("rooms")
      .Child(playerID)
      .AsObservable<string[]>()
      .Subscribe(players =>
      {
        Debug.Log(players.Object);
      }, ex =>
      {
        Debug.LogError(ex);
      });

but the observer never runs the first callback.

When i use the observer this way:

var observable = GetFirebaseClient()
      .Child("rooms")
      .Child(playerID)
      .AsObservable<object>()
      .Subscribe(players =>
      {
        Debug.Log(players.Object);
      }, ex =>
      {
        Debug.LogError(ex);
      });

it works and print this:
image

image

As expected. I don't know if this is a bug or i'm using the observer wrong.

Edit:

i fix it using this code:

GetFirebaseClient()
      .Child("rooms")
      .OrderByKey()
      .StartAt(playerID)
      .AsObservable<object>()
      .Subscribe(players =>
      {
        Debug.Log(players.Object);
      },
      ex => Debug.LogError(ex), () => Debug.Log("Completed"));

using OrderByKey and StartAt

@TomasGranda
Copy link
Author

TomasGranda commented Aug 5, 2024

Apparently my issue is that i get 2 updates. 1 when i suscribe for nothing and 1 when i modify the node i'm observing. I don't know why i'm getting 2 updates but ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant