【发布时间】:2014-10-23 22:56:06
【问题描述】:
我正在使用 Firebase 节点模块并尝试将其回调转换为 thunk 以便能够在 Koa 中使用它们。
这是根据 Firebase 文档的原始事件侦听器回调:
projects.on('value', function (snapshot) {
console.log('The read succeeded: ' + snapshot.val());
}, function (errorObject) {
console.log('The read failed: ' + errorObject.code);
});
这是我想在我的 Koa 项目中添加它的地方:
function *list() {
// Get the data here and set it to the projects var
this.body = yield render('list', { projects: projects });
}
有人知道怎么做吗?尝试过 thunkify、thunker 和 thu 都没有成功...
【问题讨论】: