如何在条件或等效条件下执行等待操作。 [英] How do I perform an await operation as while conditions or equivalence for it.?

查看:68
本文介绍了如何在条件或等效条件下执行等待操作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

我一直在使用SQLiteWinRT库,我无法实现(据我所知)在javascript的bucles中工作的异步操作的等效性。

这是一个例子:

Hi everybody.
I've been working with SQLiteWinRT library and there's no way I can't implement (the far I know) the equivalence of async operation working in bucles for javascript.
Here is an example:

await db.OpenAsync(SQLiteWinRT.SqliteOpenMode.OpenRead);
var stmt = await db.PrepareStatementAsync(
    "SELECT name FROM sqlite_master WHERE type = 'table'"
);
//this is the part
while ( await stmt.StepAsync() )
{
    string table = stmt.GetTextAt(0);
    this.ViewModel.DatabaseTables.Add(table);
}



我希望能做正确的问题。


I hope to be doing the right question.

推荐答案

我发现了我自己的解决方案。我希望这可以帮助某人

I've found the solution by myself . I hope this can help someone
stmt.stepAsync().then(function(r) {
    if (r) {
        var obj = {}, i = -1;
        while (++i < stmt.columnCount) {
            obj[stmt.getColumnName(i)] = stmt.getTextAt(i);
        }
        arr.push(obj);
        stmt.stepAsync().then(arguments.callee);
    } else {
        console.log(arr);
    }
})


这篇关于如何在条件或等效条件下执行等待操作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆