mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-15 22:26:53 +03:00
18 lines
500 B
JavaScript
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();
|
||
|
});
|
||
|
}
|