타이프 라이터를 활성화하기 위해 기능을 완료하는 때까지 실행하는 다음 기능

0

질문

나는 두 가지 기능:doAsyncStuff 및 doNextStep. 할 수 있는 방법 안 doNextStep 을 실행한 후에만 doAsyncStuff 다.

나는 그런 것 같지만 그것은 도움이 되지 않았: doAsyncStuff().then(_ => doNextStep());

async function doAsyncStuff() {
    if (vscode.workspace.workspaceFolders) {
        vscode.workspace.workspaceFolders.forEach(async (e) => {
            for (const [name, type] of await vscode.workspace.fs.readDirectory(e.uri)) {
                console.log(name);
            }
        });
    
    }
    return true;
}

function doNextStep() {
    console.log('next step');
}
async-await typescript
2021-11-23 19:10:06
1

최고의 응답

0

덕분에 많은 응답에 대한 솔루션의 hotcakedev 밖으로 작동합니다. 약속입니다.모든(vscode.작업 영역입니다.workspaceFolders.지도(비동기...리))

이처럼 보이는 방법이다(시나리오의 결과로 사용하는 비동기 재귀적 기능'readFolders'도 잘 작동하):

        await Promise.all(vscode.workspace.workspaceFolders.map(async x => {


            for (const [name, type] of await vscode.workspace.fs.readDirectory(x.uri)) {
               console.log(name);
            }
            // await readFolders(x.uri,x.uri.path);



        }));



        console.log('fin');
2021-11-23 21:44:01

다행을 도왔다!
hotcakedev

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................