This commit is contained in:
Max Lynch
2015-11-28 16:17:04 -06:00
parent f7f1acb1b6
commit 33b56579b0
84 changed files with 691 additions and 80 deletions
+16
View File
@@ -20,3 +20,19 @@ export const promisify = (pluginRef, methodName, successIndex, errorIndex) => {
})
}
}
export const wrap = (pluginRef, methodName, successIndex=null, errorIndex=null) => {
return (...args) => {
return new Promise((resolve, reject) => {
if(successIndex) {
args[successIndex] = resolve;
}
if(errorIndex) {
args[errorIndex] = reject;
}
get(window, pluginRef)[methodName].apply(this, args);
})
}
}