Firebase for MVC based projects

喜夏-厌秋 提交于 2019-12-24 20:32:39

问题


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.

来源:https://stackoverflow.com/questions/50348639/firebase-for-mvc-based-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!