【发布时间】:2018-07-07 09:18:09
【问题描述】:
我有一个函数,它通过它的 rest api 从 firebase 中提取一个数组,我需要将它输入到另一个函数中来创建一个日历。
function array_from_firebase(){
//code that pulls from firebase
return array
}
function calendar_create_from_array(array){
//code that generates calendar
}
以下不起作用:
calendar_create_from_array(array_from_firebase())
但是,这确实有效
array = array_from_firebase()
setTimeout(calendar_create_from_array,9000,array)
我相信这意味着 array_from_firebase 比 calendar_create_from_array 和 calendar_create_from_array 触发时间要长一些。
我如何使用链接和承诺来解决这个问题?
【问题讨论】:
-
你能把代码贴在这里
array_from_firebase() -
提供你到目前为止所做的事情(我假设,你应该做的,你先做了一些研究)
-
firebase 文档应该清楚如何访问结果
-
两者都不应该工作。无论
array_from_firebase做什么,都是错误的。
标签: javascript jquery chaining