brucemcpherson / desktopliberation

hosting for desktop liberation google plus community
30 stars 1 forks source link

Promises and async class constructors in Apps Script #165

Open brucemcpherson opened 3 months ago

brucemcpherson commented 3 months ago

Apps Script doesn’t do asynchronous – so what’s this all about? Since the move to v8, Apps Script supports the Promises as well as the related async/await syntax. Normally we don’t have to worry about all that since all Apps Script services are synchronous. Yet we do know that server side, plenty of asynchronous things are happening. So there is clearly a mechanism for making asynchronous things synchronous. In an imminent article I’ll be covering my port of the excellent pdf-lib library to Apps Script. Before I get to that I wanted to do a bit of background on handling Promises in Apps Script. The methods in these kind of Node ports to Apps Script libraies often return Promises. In Apps Script you’ll have to deal with the complication of async without getting the benefits. This article is to provide some background for the use of such libraries.

https://ramblings.mcpher.com/gassnippets2/promises-and-async-class-constructors-in-apps-script/