I'm working on a browser plugin using ActiveX/COM and I'm trying to pass a Javascript function to a method call so that it can be used as a callback. I've been able to get the function assigned to a property on the ActiveX object, but since the method is async all calls to the method must share the same callback.
I've seen this existing SO question but I'm not sure if this is the exact same problem since I'm not dealing directly with function pointers.
Example of what we have now:
var obj = new MyComObject();
obj.Callback = function(id) { Console.log(id); }
obj.DoMethodCallAsync("someId");
obj.DoMethodCallAsync("someOtherId"); // Uses the same callback.
Example of desired API:
var obj = new MyComObject();
obj.DoMethodCallAsync("someId", function(id) { Console.log("The first ID: " + id); }
obj.DoMethodCallAsync("someOtherId", function(id) { Console.log("The second ID: " + id); }