-
-
Save FlorianRappl/6e3428b9e558fcb9478378b9ffaba17d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = {}; | |
window.getData = name => { | |
const item = data[name]; | |
return item && item.value; | |
} | |
window.setData = (owner, name, value) => { | |
const previous = data[name]; | |
if (!previous || previous.owner === owner) { | |
data[name] = { | |
owner, | |
name, | |
value, | |
}; | |
window.dispatchEvent(new CustomEvent('changed-data', { | |
detail: { | |
name, | |
previous: previous && previous.value, | |
current: value, | |
}, | |
})); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment