首页 \ 问答 \ Scala函数调用(Scala function call)

Scala函数调用(Scala function call)

我在几个框架中发现了以下函数调用,在我看来,框架扩展了一些基类。 一些例子:

within(500 millis)

要么

"Testcase description" in
  { .... }

第一个示例从akka返回持续时间为500毫秒的持续时间对象,第二个示例从scalatest中定义一个测试用例。

我想知道这种行为是如何实现的以及它是如何被调用的。


I have found following function calls in several frameworks which appear to me as if the framework extends some base classes. Some examples:

within(500 millis)

or

"Testcase description" in
  { .... }

First example returns a duration object with the duration of 500 milliseconds from akka and second is the definition of a testcase from scalatest.

I would like to know how this behavior is achieved and how it is called.


原文:https://stackoverflow.com/questions/5953756
更新时间:2022-01-20 10:01

最满意答案

你什么都不缺。 这就是目前的工作方式。 我不喜欢它。 这很常见,因为它发生在chrome自动更新扩展时,即使在使用中也是如此。
我通过检测您提到的具体错误在我的扩展中处理此问题。 然后每个内容页面显示一个小的无模式对话框,告诉用户忽略或重新加载网页。 对于Trello镀铬扩展,加上2天前的版本。 虽然它不是很好,但我把它作为一个机会,用moddless对话框中的链接告诉用户有关新功能的信息。
另外,如果你想在后台捕获它,只需解析你的清单(作为资源公开)并在本地存储中保存最后一个版本。 你会发现它已更新。 还有onUpdated但我从未使用它。
我想如果你真的必须从内容到新扩展进行通信,你可以在固定的storage.local属性中写一条消息。 存储的后台寄存器更改并通过读取存储并在处理后删除它来检测挂起的消息。 除非您还使用本地存储空间进行回复并在内容方面进行相同的观看,否则无法回复。


you arent missing anything. this is how it currently works. i dont like it either. this is very common because it happens when chrome auto updates an extension, even while in use.
i deal with this in my extension by detecting that specific error you mention. each content page then displays a small moddless dialog telling the user to either ignore or Reload the webpage. Plus for Trello chrome extension does this as of 2 days ago. while its not great, I took it as an oportunity to tell the users about new features using a link in the moddless dialog.
also, if you want to catch this on the background side, just parse your manifest (expose as a resource) and save in local storage the last version. you will detect it was updated. there is also onUpdated but ive never used it.
i guess if you really must communicate from content to the new extension you could write a message in a fixed storage.local property. background registers for storage changes and detects pending messages by reading that storage and removing it once processed. cant reply back unless you also use a local storage for the reply and do the same watching on the content side.

相关问答

更多
  • 根据官方文档,您应该在接收方的发送方和message事件侦听器中使用postMessage 。 这里是一个例子: 您的网站的page.html var data = { type: "FROM_PAGE", text: "Hello from the webpage!" }; window.postMessage(data, "*"); 内容脚本:(使用chrome.tabs.executeScript(tabid, {code:... )注入) window.addEventListener("mess ...
  • 您的contentscript.js只是一个用JavaScript编写的程序指令的文件。 每次将这些指令加载到特定的执行环境中时,这些指令都被解释为新的和新的。 您的弹出窗口和内容脚本是独立的执行环境。 contentscript.js文件本身不存储状态。 当contentscript.js被加载到内容脚本环境中时,内容脚本执行环境不知道还包括了哪些contentscript.js 。 这里使用的正确模式是让后台页面保持状态并记住上次捕获的选项卡的选项卡ID。 弹出窗口将使用消息传递将当前选项卡ID发送到后 ...
  • 从chrome.runtime.onMessage.addListener的文档 : 当事件侦听器返回时,此函数将无效,除非您从事件侦听器返回true,以指示您希望异步发送响应(这将使消息通道在另一端保持打开,直到sendResponse被调用)。 所以你只需要添加return true; 在调用getUrls ,表示您将异步调用响应函数。 From the documentation for chrome.runtime.onMessage.addListener: This function becom ...
  • 您错误地将已弃用的"background_page"属性与"background_page"的新签名混合在一起。 使用背景页面的正确方法是: "background": { "scripts": ["background.js"] } 你可以完全摆脱你的background.html ,因为它没有用处(你的内容未被使用)(如果你真的需要它,请使用"background": {"page": "background.html"} )。 关于sendRequest ,它确实已被弃用,但尚未 ...
  • 由于每次加载弹出窗口时都会发送从弹出窗口到内容脚本的消息,因此请务必重新加载页面以确保加载内容脚本。 否则,您最终可能会收到以下错误: Could not establish connection. Receiving end does not exist. 也就是说,我尝试了你提供的东西,它按原样运行。 由于您的输出位于popup.js中,因此响应位于弹出窗口的控制台输出中。 您可以通过右键单击浏览器操作图标并选择“检查弹出窗口”来查看它。 Since the message from your pop ...
  • 如果在表单中单击type="submit"的按钮,默认情况下浏览器将在提交表单后重新加载页面。 要防止页面重新加载,请将type="submit"替换为type="button"或者在sendValues处理程序中调用e.preventDefault() 。 附录: 根据MDN ,按钮的默认值是submit 。 类型 按钮的类型。 可能的值是: submit:该按钮将表单数据提交给服务器。 如果未指定属性 ,或者属性动态更改为空值或无效值,则这是默认值。 reset:该按钮将所有控件重置为初始值。 按钮:该 ...
  • 你什么都不缺。 这就是目前的工作方式。 我不喜欢它。 这很常见,因为它发生在chrome自动更新扩展时,即使在使用中也是如此。 我通过检测您提到的具体错误在我的扩展中处理此问题。 然后每个内容页面显示一个小的无模式对话框,告诉用户忽略或重新加载网页。 对于Trello镀铬扩展,加上2天前的版本。 虽然它不是很好,但我把它作为一个机会,用moddless对话框中的链接告诉用户有关新功能的信息。 另外,如果你想在后台捕获它,只需解析你的清单(作为资源公开)并在本地存储中保存最后一个版本。 你会发现它已更新。 还 ...
  • 必须在第二个扩展(接收消息) 之后加载第一个扩展(发送消息)。 这很明显:当它们以相反的顺序加载时,发送方会在创建接收方之前发送消息。 The first extension (which sends the message) has to be loaded after the second extension (which receives the message). This is obvious: When they're loaded in the reverse order, the sende ...
  • 要从stdin读取json数据: int _tmain(int argc, _TCHAR* argv[]) { unsigned int length = 0; //read the first four bytes (=> Length) for (int i = 0; i < 4; i++) { length += getchar(); } //read the json-message string msg = ""; for (int i = 0; i < length; i++) { ...
  • 代码中的问题 if(request.message=="execute"){ alert("message received!"); }else if{ alert("message not received!"); } else if{在java脚本中使用else {没有else if{ 。 工作版 background.html

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。