neuecc / UniRx

Reactive Extensions for Unity
MIT License
7.08k stars 891 forks source link

Just One Line of Code Away From Working with firebase-database-dotnet for Unity! #266

Open bryanedds opened 6 years ago

bryanedds commented 6 years ago

Hi!

I'm writing to notify you that, beyond just a few define conditionals, UniRx is only one line of code away from working with the firebase-database-dotnet client here -

https://github.com/step-up-labs/firebase-database-dotnet

The only remaining line of code that doesn't compile in firebase-database-dotnet using UniRx is the following in RealtimeDatabase.GetInitialPullObservable() -

return Observable.Defer(async () => Observable.Return(await query.OnceSingleAsync<T>()).Select(e => new[] { new FirebaseObject<T>(this.elementRoot, e) }));

https://github.com/step-up-labs/firebase-database-dotnet/blob/master/src/Firebase/Offline/RealtimeDatabase.cs#L249

It appears that UniRx does not yet include the Func<Task> overload for Defer, making the use of async unworkable. If I remove the use of async syntax and grab the task result directly like so -

return Observable.Defer(() => Observable.Return(query.OnceSingleAsync<T>()).Select(e => new[] { new FirebaseObject<T>(this.elementRoot, e.Result) }));

I also reported this to the firebase-database-dotnet team, so that way, perhaps y'all can work together on a solution here - https://github.com/step-up-labs/firebase-database-dotnet/issues/120

Cheers!

grofit commented 6 years ago

If you are just missing an overload raise it as a PR and hopefully it will get merged in.