Closed redtopia closed 5 years ago
It's not reliable in all circumstances. I recommend typing the 5 extra characters. If you use the scope in many places in the method then you can set an alias to it at the top, e.g.
function onOpen(...) {
var app = arguments.applicationScope;
// now use app
}
Thanks Igal. Could you elaborate under which circumstances would it be unreliable? I'm just trying to get a feel for why/how.
I honestly do not remember the details and do not have the time to dig into the code. I just remember that there is a reason for it, most likely because the events are asynchronous. It's possible that in onOpen() it would work but in other event handlers it would not, so it's more consistent to do it that way.
I thought that the
Application
scope could only be accessed via the applicationScope argument in the listener methods as described in the docs/api. However, I just realized that I can access theApplication
scope directly. For example, the application scope argument is namedapplicationScope
in theonOpen()
method, yet I can dump theapplication
variable and it's what I expect it to be. Is this expected behavior, or is this some weird side effect?