Skip to content

Instantly share code, notes, and snippets.

@rgruesbeck
Last active April 12, 2019 20:46
Show Gist options
  • Save rgruesbeck/174d29f244494ead21e2621f6f0d79ee to your computer and use it in GitHub Desktop.
Save rgruesbeck/174d29f244494ead21e2621f6f0d79ee to your computer and use it in GitHub Desktop.
koji live preview injection
// listen for post message
// you will need to attach the listener to window instead of document for this to work
window.addEventListener("message", injectHandler, false);
// handle the update
function injectHandler({ data }) {
if (data.action === 'injectGlobal') {
let { scope, key, value } = data.payload;
config[scope][key] = value;
load();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment