首页 > 解决方案 > withObservables 和 await

问题描述

我正在使用AsyncStorage并尝试在withObservables查询中使用其中一个存储的会话详细信息来存储一些会话详细信息。例如,假设这getCurrentFruitID是一个异步辅助方法来检索fruitIDfrom AsyncStorage。我尝试编写的代码如下所示:

compose(
  withDatabase,
 from(() => )
  withObservables([], async ({database}) => ({
    fruit: database
        .get('fruits`)
        .query(Q.where('fruit_id', await getCurrentFruitID()),
  })),
)(Component)

但这会导致undefined is not an object错误。from正如官方论坛中的另一个人所建议的那样,我在 RxJS ( https://rxjs-dev.firebaseapp.com/api/index/function/from )中使用了该函数,但没有运气。任何帮助将非常感激!

标签: javascriptreact-nativerxjswatermelondb

解决方案


推荐阅读