--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/24d00657-9e86-4e01-92f2-582897717d4d%40googlegroups.com.
Note that this doesn't all work with libraries at the time of writing. If you want to expose a class from a library, you'll need to make a factory function (using the old function syntax)
class yourClass { .... } // to enable use of classes from a library function newYourClass (...args) { return new yourClass (...args) } /// and in your main app - access it like this const yourInstance = yourLibrary.newYourClass(arg1,arg2)
Similarily, v8 has a problem where namespaces defined with const or arrow functions are not visible in from libraries. Here's a workaround
const Settings = (() => { return { ... whatever } })() // to make this visible when a library var LibSettings = Settings // and in your main app - access it like this const settings = yourLibrary.LibSettings
class MyFile {
static open ({file}) {
return file
}
constructor (options) {
this._file = this.constructor.open(options)
}
get file () {
return this._file
}
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/5b9b5edf-f6b6-42f0-bc55-7683bceccefb%40googlegroups.com.
// go through the files
while (files.hasNext()) {
// get google drive file
const file = v8.newMyFile(files.next())
Can you share how you’re calling it? Options would need to have a property of .file for this to work.
On Tue, Mar 17, 2020 at 4:06 PM Jacob Jan Tuinstra <jaco...@familietuinstra.nl> wrote:
Hi Bruce,--Can I pass on an object as an argument to a class? Want to pass on files.next() to create a MyFiles class. Created a MyFolders class with succession !!This is how I planned on doing it, but it returns undefined.
class MyFile {
static open ({file}) {
return file
}
constructor (options) {
this._file = this.constructor.open(options)
}
get file () {
return this._file
}Can you shed a light?Regards Jacob Jan
On Saturday, 14 March 2020 16:10:14 UTC+1, Bruce Mcpherson wrote:V8 brings some changes in the order in which things are done on initialization. This means that things in the global space may not behave the same as they in did in legacy apps script.Here's a write up of a small project that shows how namespaces avoids those kind of issues.https://ramblings.mcpher.com/apps-script/apps-script-v8/apps-script-v8-multiple-script-files-and-namespaces/
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/3d63bf10-bf2b-4171-8e8b-3ef09943427e%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CALptO3LE007WZNFNNDCWyeBzLHgraVkk0hDQGX-qCBth_zeJ9g%40mail.gmail.com.