Firebase Realtime with Notification

I’m trying to show a notification for extracted data. For some reason the data is successfully extracted but the notification is not shown. Mind you the notification is shown when not inside the onDataChange method. What could be the problem? The logs show the data is being extracted but it’s like any Vaadin component inside the onDataChange method is ignored. If the notification is placed outside of the onDataChange method it is shown.

Sounds like a different thread, which means you need Push.

Using a different thread doesn’t work. Am I using it wrong??

You have to pass the UI instance to your method. And add Push annotation like described in the docs

Annotate that class with @UIScoped and some stereotyped @SpringComponent making that if the is in another thread an exception is thrown.

And if you can log with @Slf4j or @Log4j2 that will show you the thread where that occurs, it makes it easier for you.

You can also use the UI instance by overwriting the onAttach method in that class.

Anyway do you have that listener in another thread ?

Pass the entire class.

With the access method what you do is to update a vaadin component correctly from another thread.

But it is not that you make an execution in another thread with it.