Skip to content

Instantly share code, notes, and snippets.

@colelawrence
Created July 28, 2016 16:39
Show Gist options
  • Select an option

  • Save colelawrence/6bf36ad9c2b22f46835da887b20a1f54 to your computer and use it in GitHub Desktop.

Select an option

Save colelawrence/6bf36ad9c2b22f46835da887b20a1f54 to your computer and use it in GitHub Desktop.
// Helper function gets element of type T from parent dom element
function getElement<T>(parent: HTMLElement, selector: string): Promise<T> {
return new Promise<T>((resolve, reject) => {
setTimeout(
() => {
try {
resolve(<T><any> parent.querySelector(selector));
} catch (error) {
reject(error);
}
},
0
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment