Firestore: Serve cached datas first

泄露秘密 提交于 2019-12-12 13:08:36

问题


Firestore can handle offline persistence but it doesn't seem to load cached datas first. Is that possible ? The app perf would seem much better if the local datas were loaded first.

If not possible, is there an easy way to get the local datas manually so I can do an Observable merge and load cached datas first.

Thanks a lot

EDIT:

I'm using angularfire2 with Ionic 3.

I'm expecting an offline first behavior from Firestore. Since valueChanges() returns an Observable, I think it should first emit the local value then when the remote datas have arrived emit the remote value.

For instance, if I do this:

return this.db.collection<HeroServerData>('game/heroes')
  .valueChanges()
  .map(heroes => heroes.map(hero => new Hero(hero)));

I can see that the data are cached locally but I still have to wait for the server response or a timeout (if offline) to get the datas

来源:https://stackoverflow.com/questions/46649022/firestore-serve-cached-datas-first

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