Calendar access example

Just a heads up. I will recommend using await instead of .then, especially in Scriptable. This means that the following:

Photos.latestPhoto().then(photo => {
  // ...
})

Becomes:

let photo = await Photos.latestPhoto()

There’s several reasons I would recommend that, both in general and in terms of Scriptable.

  1. When you get used to it, you’ll most likely find that it’s much more readable and easier to write.
  2. For now it helps Scriptable determine when your script has finished running which is used in various cases. It’s not super critical but it will give a slightly improved experience when using the app and Siri Shortcuts.
  3. Ultimately I’d like to reduce the amount of promises used in the app. This is something I haven’t found the best approach for yet and even if I had, I don’t have the time for it for version 1.0. If you’re using await, migration will most likely be easier when the day comes.

There might be cases where you want to use .then() but for the cases where it doesn’t matter, consider using await.

1 Like