This isn't exactly a valid syntax. See, when you use await, it will return the actual data and not the Promise so you can't use .catch() there. Also .catch()'s parameter needs to be a function, not a function call.
Whenever possible, try not to mix the use of async/await vs Promise.then().catch()
Either do this
try {
var ret = await tryClass("Alert")
// do something with ret
} catch(e) {
err(e)
}
or
tryClass("Alert")
.then( (ret) => {
// do something with ret
})
.catch( err )
Try Timer.schedule and add 550 ms. make callbackfunction the next UI command. for e.g Calender.presentPicker. System take some time to convert scriptable's js code and onto the the swift/objc source code. So thats why you can't have one item after the another. they mush have some code between them that alteast takes 550ms (depending on device) to run.
I was just making a developer guide example sets for scriptable. Yes docs are there but as a developer (java previously) its easier to see code in action than to ponder and assume how things fits together practically.
So I decided to just use switch statements for this issue. That way I only make one call per example.
1
u/nilayperk Aug 27 '21
I have been trying to use async and await. But scriptable just hangs after the first
await alertPresentAlert()2
u/[deleted] Aug 28 '21
await tryClass("Alert").catch(err("class"))
This isn't exactly a valid syntax. See, when you use
await, it will return the actual data and not thePromiseso you can't use.catch()there. Also.catch()'s parameter needs to be a function, not a function call.Whenever possible, try not to mix the use of async/await vs Promise.then().catch()
Either do this
or
2
u/[deleted] Aug 28 '21
[removed] — view removed comment