From 54788e9256ccb7d0f7156d91e4cec1736ecdc477 Mon Sep 17 00:00:00 2001 From: Ian Sanders Date: Thu, 22 Feb 2024 09:10:16 -0500 Subject: [PATCH] Improve docs on function declarations --- readme.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 17b797e..c011b2c 100644 --- a/readme.md +++ b/readme.md @@ -99,13 +99,13 @@ to the engine. In the traditional Google Apps Script environment, you'd do this functions, however in this setup there is no concept of 'global' as all files are modules. Instead, all (and only) functions exported from `index.ts` will be available to Google Apps Script. -Any function added to the `global` object will be available= to all +Any function exported from `index.ts` will be accessible by all [triggers](https://developers.google.com/apps-script/guides/triggers) and anywhere else Google Apps might need to call your function, such as from a [custom menu](https://developers.google.com/apps-script/guides/menus). Examples for all the simple triggers are given in -[`index.ts`](https://github.com/iansan5653/gas-ts-template/blob/master/src/index.ts#L39-L43). +[`index.ts`](https://github.com/iansan5653/gas-ts-template/blob/master/src/index.ts). For cleaner, more usable code, it may be useful to reference functions by their `name` property instead of hardcoding the name into code. For example: @@ -113,7 +113,10 @@ For example: ```ts const createButton = CardService.newTextButton() .setText("Create") - .setOnClickAction(CardService.newAction().setFunctionName(onClickCreateEvent.name)); // instead of "onClickCreateEvent" + .setOnClickAction( + // Here we use `onClickCreateEvent.name` instead of hardcoding `"onClickCreateEvent"` + CardService.newAction().setFunctionName(onClickCreateEvent.name) + ); ``` ### Circular Dependencies