redux-devtools/extension/test/utils/inject.js
Nathan Bierema 6782f4ae41
chore(extension): add extension (#658)
* Move extension

* prettier
2020-10-26 08:18:23 -04:00

18 lines
500 B
JavaScript

export function insertScript(str) {
const s = window.document.createElement('script');
s.appendChild(document.createTextNode(str));
(document.head || document.documentElement).appendChild(s);
}
export function listenMessage(f) {
return new Promise((resolve) => {
const listener = (event) => {
const message = event.data;
window.removeEventListener('message', listener);
resolve(message);
};
window.addEventListener('message', listener);
if (f) f();
});
}