且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Firebase Firestore中获取单个文档数据(无承诺)

更新时间:2023-02-14 10:03:07

正如Jaromanda X所说:您***接受Firebase和大多数现代Web的异步特性.您越早掌握编程模式,就越早可以恢复这种范例的生产力.

As Jaromanda X commented: you're best of accepting the asynchronous nature of Firebase and most of the modern web. The sooner you get to grips with the programming patterns, the sooner you can get back to being productive in this paradigm.

我发现重新构造问题最有帮助.我将其构架为首先开始加载文档.加载文档后,对其进行操作",而不是加载文档,然后对其进行处理".

I find it most helpful to reframe problems. Instead of "Load a document, then do something with it" I frame it as "First start loading a document. Once the document has loaded, do something with it".

实际上,这意味着您将需要文档的代码移入到现在具有日志记录语句的完成处理程序中.

In practice that means that you move your code that needs the document into the completion handler where you now have the logging statements.