step-up-labs / firebase-database-dotnet

C# library for Firebase Realtime Database.
MIT License
668 stars 168 forks source link

Real-time is not displaying #304

Closed Christophershivers closed 1 year ago

Christophershivers commented 1 year ago

I followed this tutorial for triggering a real-time update when there's a database change. However, it's not listing anything. When I list the objects from the database it works. But when I try to use AsObservable and Subscribe it doesn't display. I'm using firebase for web, and utilizing Asp.net core MVC

public IActionResult List()
        {

            var student = new List<StudentModel>();

            var data = db.Child("Student").AsObservable<StudentModel>().Subscribe((dbevent) => 
            { 
                if(dbevent.Object != null)
                {
                    student.Add(dbevent.Object);
                }
            });
            return View(student);
        }
bezysoftware commented 1 year ago

The method List completes before any items are pushed to the Subscribe lambda. The lambda is called whenever there is something new, asynchronously, it doesn't wait.

Christophershivers commented 1 year ago

The method List completes before any items are pushed to the Subscribe lambda. The lambda is called whenever there is something new, asynchronously, it doesn't wait.

How do i get it to push the items before it's finished?