ghi-electronics / due-libraries

Demo
https://ghi-electronics.github.io/due-libraries/
0 stars 2 forks source link

JS forEach fails with API #35

Closed gus-ghielec closed 1 year ago

gus-ghielec commented 1 year ago

This does not work as expected

await BrainPad.System.Println("test");

let nameList = ["Bob","Lisa","Gus","Tina"];

nameList.forEach(async function (value) {
    await BrainPad.System.Println(value);
}); 
gus-ghielec commented 1 year ago

It is as if we forgot to add await

taylorza commented 1 year ago

This is an issue with Javascript, the lambda function is not awaited in the forEach. We should recommend using for..of

let nameList = ["Bob","Lisa","Gus","Tina"];

for(const name of nameList) {
    await BrainPad.System.Println(name);
}
gus-ghielec commented 1 year ago

BP docs updated