Firebase synchronisation of locally-modified data: handling errors & global status

社会主义新天地 提交于 2019-11-27 23:15:50

In the example above, what kind of errors should the fredRef.remove() callback expect to receive?

Client is offline (network connection lost) ?

No, this will not cause an error to be passed to the completion listener. It will simply cause the completion listener to not be called (yet).

Firebase server is temporarily overloaded or down for maintenance, but will be available again soon?

No. This is essentially the same as being without a network connection.

Permission denied (due to security rules) ?

Yes, this is will indeed cause an error to be passed to the completion handler.

Database location does not exist?

No, this will not cause an error to be caused to the completion listener.

If isConnected is true, does this also mean that all modified data has been synced to the server? i.e. Does "connected" also mean "synced"?

No it does not. .info/connected will fire with true when a connection is made to the database.

If not, how can the app determine the global sync status of the whole Firebase client?

There is currently no way to determine whether your local data is up to date with the server.

Is there a special /.info/synchronized location?

No, such a location doesn't exist.

Does the app need to manually keep track of the sync success/failure result of every onComplete callback?

That depends on the use-case. But if you want to simply know when all your writes are executed, push a dummy value and wait for that to complete. Since Firebase executes the writes in order, you can be certain at that stage that you've gotten the other events.

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