step-up-labs / firebase-database-dotnet

C# library for Firebase Realtime Database.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Real-time is not displaying

Christophershivers opened this issue · comments

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);
        }

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.

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?