Is there any example on how to load a plugin with TypeScript?
We had that working with JavaScript but it looks like we are now going to TypeScript.
Ok. I just ported that JavaScript function used as a class to TypeScript. Works the same:
export class OverwolfPlugin {
iExtraObjectName: string;
iAddNameToObject: boolean;
iPluginInstance: any;
constructor(aExtraObjectNameInManifest: string, aAddNameToObject: boolean) {
this.iExtraObjectName = aExtraObjectNameInManifest;
this.iAddNameToObject = aAddNameToObject;
}
get() {
return this.iPluginInstance;
}
initialize(callback) {
var proxy = null;
try {
proxy = overwolf.extensions.current.getExtraObject;
} catch (e) {
console.error(
"overwolf.extensions.current.getExtraObject doesn't exist!");
return callback(false);
}
var extraObjectName = this.iExtraObjectName;
var addNameToObject = this.iAddNameToObject;
var self = this;
proxy(self.iExtraObjectName, function (result) {
if (result.status != "success") {
console.error(
"failed to create " + self.iExtraObjectName + " object: " + result);
return callback(false);
}
self.iPluginInstance = result.object;
if (self.iAddNameToObject) {
self.iPluginInstance._PluginName_ = self.iExtraObjectName;
}
return callback(true);
});
}
}