dispatch

Is it possible to dispatch events on regular objects (not DOM ones)? [duplicate]

懵懂的女人 提交于 2019-11-30 12:51:57
问题 This question already has answers here : Can plain Javascript objects have events? (8 answers) Closed 2 years ago . I just found out that FileReader dispatches events just as if it was a DOM element. Is it? I wonder if it's possible to create an object similar to FileReader, which doesn't have a representation in HTML/XML structure, but can dispatch events? 回答1: FileReader has methods like addEventHandler because it is defined to implement the EventTarget interface. EventTarget is defined by

Is S4 method dispatch slow?

廉价感情. 提交于 2019-11-30 05:12:12
My S4 class has a method that is called many times. I noticed that the execution time is much slower than it would be if a similar function was called independently. So I added a slot with type "function" to my class and used that function instead of the method. The example below shows two ways of doing this, and both of them run much faster than the corresponding method. Also, the example suggests that the lower speed of the method is not due to method having to retrieve data from the class, since the functions are faster even when they also do that. Of course, this way of doing things is not

Difference between func() and (*this).func() in C++

我是研究僧i 提交于 2019-11-30 04:37:02
I am working on someone else code in C++, and I found a weird call to a certain function func() . Here is an example: if(condition) func(); else (*this).func(); What is the difference between func() and (*this).func() ? What are the cases where the call to func() and (*this).func() will execute different code? In my case, func() is not a macro. It is a virtual function in the base class, with an implementation in both base and derived class, and no free func() . The if is located in a method in the base class. There actually is a difference, but in a very non-trivial context. Consider this

Is it possible to dispatch events on regular objects (not DOM ones)? [duplicate]

我只是一个虾纸丫 提交于 2019-11-30 03:58:31
This question already has an answer here: Can plain Javascript objects have events? 8 answers I just found out that FileReader dispatches events just as if it was a DOM element. Is it? I wonder if it's possible to create an object similar to FileReader, which doesn't have a representation in HTML/XML structure, but can dispatch events? FileReader has methods like addEventHandler because it is defined to implement the EventTarget interface. EventTarget is defined by the DOM Events spec but you don't need to be a DOM object to implement it. window , XMLHttpRequest and FileReader are other

target parameter in DispatchQueue

时光怂恿深爱的人放手 提交于 2019-11-30 02:53:02
问题 In Swift 3, the creation of a DispatchQueue instance: DispatchQueue(label: String, qos: DispatchQoS, attributes: DispatchQueue.Attributes, autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency, target: DispatchQueue?) I see the sample codes from StackOverFlow, it can be nil, .global() or .main, what's the meaning of this target parameter? I guess .main means the queue will run on main thread, but what for .nil or .global() ? 回答1: There's no documentation for Swift so I dropped back to the

Get current dispatch queue?

冷暖自知 提交于 2019-11-30 01:46:09
I have a method which should support being called from any queue, and should expect to. It runs some code in a background thread itself, and then uses dispatch_get_main_queue when it returns a value to it's block argument. I don't want it to force it onto the main queue if it wasn't when it entered the method. Is there a way to get a pointer to the current dispatch queue? Michael Dautermann You do have the option of " dispatch_get_current_queue() " , however the iOS 6.1 SDK defines this API with these disclaimers: " Recommended for debugging and logging purposes only: " and " This function is

Dispatch CLI not passing Entities from Luis App

删除回忆录丶 提交于 2019-11-29 17:33:01
When generating a Dispatch model using the CLI, it doesn't pass the Entities from the Luis app in reference. This drastically affects the accuracy of the dispatch app. For example, for the utterance "My [iPhone] isn't working", iPhone is attached to an entity list name CellPhoneType. There are three items in the list iPhone, Samsung, Smartphone. In the bot emulator, using the Dispatch, if I write "my iPhone isn't working", the dispatch model passes it to Luis, as it should. However, if I write "my smartphone isn't working", the dispatch tool sends it over to QnA Maker. I checked the model, and

win32com.client.Dispatch works but not win32com.client.gencache.EnsureDispatch

穿精又带淫゛_ 提交于 2019-11-29 15:05:48
i'm learning win32com for python and I've got a strange problem. I'e trying to export Outlook Contacts in a List of Dictionnary. My code works perfectly with win32com.client.Dispatch("Outlook.Application). But it returns 0 contacts with win32com.client.gencache.EnsureDispatch("Outlook.Application) that is supposed to be faster and "safer". Here's my code : class MapiImport(): def __init__(self): self.olApp = win32com.client.Dispatch("Outlook.Application") self.namespace = self.olApp.GetNamespace(u"MAPI") # olFolderContacts = 10 : self.mapiContacts = self.namespace.GetDefaultFolder(10).Items

Why virtual function call is faster than dynamic_cast?

帅比萌擦擦* 提交于 2019-11-29 09:20:40
问题 I wrote a simple example, which estimates average time of calling virtual function, using base class interface and dynamic_cast and call of non-virtual function. Here is it: #include <iostream> #include <numeric> #include <list> #include <time.h> #define CALL_COUNTER (3000) __forceinline int someFunction() { return 5; } struct Base { virtual int virtualCall() = 0; virtual ~Base(){}; }; struct Derived : public Base { Derived(){}; virtual ~Derived(){}; virtual int virtualCall(){ return

Fastest implementation of simple, virtual, observer-sort of, pattern in c++?

馋奶兔 提交于 2019-11-29 08:08:11
I'm working my arse off trying to implement an alternative for vtables using enums and a ton of macro magic that's really starting to mess with my brain. I'm starting to think i'm not walking the right path since the code is getting uglier and uglier, and will not be fit for production by any means. How can the pattern of the following code be implemented with the least amount of redirection/operations? It has to be done in standard c++, up to 17. class A{ virtual void Update() = 0; // A is so pure *¬* }; class B: public A { override void Update() final { // DO B STUFF } } class C: public A {