如何在Google Apps脚本中异步运行方法?(How can I run a method asynchronously in Google Apps Script?)
当有些数据通过表单提交时,我有一个由客户端调用的函数。 这会触发一个操作,向希望接收通知的个人发送电子邮件。 问题是这必须与表单提交同步完成,因此提交表单的用户必须等待电子邮件发送,然后才能从Apps脚本收到返回数据,说明提交成功。
这有时需要几秒钟。 有没有办法在应用程序脚本中异步运行一个函数(所以服务器可以在发送电子邮件时向客户端返回一条消息)?
或者甚至更好,创建一个我可以收听类似于.NET事件的事件?
I have a function that's called by the client when some data is submitted via a form. This triggers an action that sends an email out to individuals that wish to receive notifications. The problem is that this has to be done synchronously with the form submit, so the user submitting the form has to wait for the emails to be sent before they receive the return data from Apps Script saying that the submission was successful.
This can sometimes take several seconds. Is there a way to asynchronously run a function in apps script (So the server can return a message to the client while the emails are being sent)?
Or even better, create an event that I can listen to similar to events in .NET?
原文:https://stackoverflow.com/questions/35025771
最满意答案
我能看到这样做的唯一方法是提供接口是第三个项目。 让具有相反项目类的构造函数取代接口。
The only way I can see to do this is to provide interfaces is some third project. Have the constructors that take the opposite project's class take the interface instead.
相关问答
更多-
我找到了答案。 看来我运行的测试代码很好,但对模块的旧版本。 在我的代码的以前版本中,ClassB不存在,而ClassA则存在。 更新我的代码后,我应该运行以下内容来安装它。 sudo pip install ./ --upgrade 在安装运行pytest的更新模块时产生了正确的结果(因为我使用的是正确的代码库)。 [procyclinsur@localhost unit]$ pytest ============================================== test sessio ...
-
您可以尝试将此__str__实现用于Mazo : def __str__(self): return str([str(k) for k in self.mazo]) 编辑:如果您希望您的类支持索引,您可以实现方法__getitem__ : def __getitem__(self, index): return self.mazo[index] You can try using this __str__ implementation for Mazo: def __str__(sel ...
-
这里的关键是Objective-C对象总是指针 。 如果不是这个事实,两个结构的大小将是无限的(由于循环引用)。 在适当的Objective-C中,类看起来像这样: @class classA; @class classB; @interface classA { classB * objB; } @end @interface classB { classA * objA; } @end 在这种情况下,两个类的大小都是一个指针的大小。 The key here is that Obj ...
-
将一个类转换为另一个类的代码(我假设您正在讨论运行时转换)可能不是必要的方法。 例如,如果你有类X和类Y,每个类都有你希望从方法C调用的void Blah() ,而方法C将X作为参数,你可能会做的是为X和Y提取一个公共接口然后让C接受接口。 因此你的Y可以保持Y. 另一个选择是使用适配器模式 ,它可以使Y符合X的提取接口,如果Y具有相同的一般功能但名称不同,或者更改其中一个类的代码是痛苦的,这将特别有用。 ,不可能,或者只是不受欢迎。 给出一个例子 interface ICanBlah { void Bla ...
-
Json深入对象(Json to Object deeply)[2022-11-02]
你需要做这样的事情: export interface ClassBData { name: string; } export interface ClassAData { name: string; classB: ClassBData; } export class ClassA { name: string; classB: ClassB; constructor(json: ClassAData) { this.name = js ... -
在A班:发布通知 [[NSNotificationCenter defaultCenter] postNotificationName:@"DataUpdated" object:self]; 在B类中:首先注册通知,然后编写一个方法来处理它。 您将相应的选择器赋予该方法。 // view did load [[NSNotificationCenter defaultCenter] addObs ...
-
JavaScript模式:将ClassA属性“复制”到ClassB(JavaScript pattern: “copy” ClassA properties to ClassB)[2023-09-24]
如果ClassA构造函数为空,那么这里没有什么大惊喜 - call ClassA的空构造函数绝对没有任何意义。 但是,当你决定要让ClassA的构造函数非空时,你会看到该行现在具有非常重要的作用:构造一个ClassB对象也会在新构造的上下文中调用ClassA特定的构造函数行为。 ClassB对象,如果ClassB是ClassA的逻辑“子类”,那就是您所期望的。 (当然,JavaScript没有合适的“子类”,但这显然是尝试在语言中实现基于类的行为。) If the ClassA constructor is ... -
.classA样式的.classA样式可以轻松制作动画吗?(can a .classA styles to .classB styles be animated easly?)[2022-11-07]
你可以用jQueryUI / switchClass来做 ,你只需要一个自定义构建的jQueryUI并启用了Effects Core - 没有别的,大约是11k缩小了 例 $( ".element_to_be_animated" ).switchClass( "oldClass", "newClass", 1000 ); You can do it with jQueryUI/switchClass, you only need a custom build of jQueryUI with Effect ... -
我能看到这样做的唯一方法是提供接口是第三个项目。 让具有相反项目类的构造函数取代接口。 The only way I can see to do this is to provide interfaces is some third project. Have the constructors that take the opposite project's class take the interface instead.
-
试试这个: function Coord(x, y) { this.x = x; this.y = y; } function Ellipse(text, cx, cy, rx, ry) { this.text = text; var c = new Coord(cx, cy); var r = new Coord(rx, ry); } 我不知道你怎么想Coord C = new C()但这绝对是错的。 JavaScript变量没有类型。 你也从哪里得到Text ...