本文介绍了如何在条件或等效条件下执行等待操作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。 我一直在使用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); } })
更多推荐
如何在条件或等效条件下执行等待操作。
发布评论