Moving to a class-based approach

This commit is contained in:
Max Lynch
2015-11-25 11:44:58 -06:00
parent e455e8ebcf
commit 188079fdef
16 changed files with 163 additions and 38 deletions
+16
View File
@@ -1,6 +1,22 @@
declare var window;
declare var Promise;
export function get(obj, path) {
for (var i=0, path = path.split('.'), len = path.length; i < len; i++) {
obj = obj[path[i]];
}
return obj;
};
export const promisify = (pluginRef, methodName, successIndex, errorIndex) => {
return (...args) => {
return new Promise((resolve, reject) => {
args[successIndex] = resolve;
args[errorIndex] = reject;
get(window, pluginRef)[methodName].apply(this, args);
})
}
}