I'm struggling with Firebase
due to it's asynchronous behavior. Let me explain what problem I'm facing
As you know in MVC we do logic in our Controller, and then pass the output or data to the VIEW. But using Firebase
we can't pass data to the view because Controller will not wait for Firebase
response and will initialize the VIEW.
class Controller{
index(){
var data = getDataFromFirebase(); // controller will not wait for this
return view('users', data);
}
}
So how we can handle this situation? How to get the data from the Firebase
and then pass to the View in Controller.
I have test it in Laravel
, Adonisjs -NodeJS Framework
, Spring Boot MVC
But not works in any framework to check may be there could be a solution for this problem but didn't found any one. You can suggest the solution in any framework or language as I mentioned.