03-20-2020 05:55
03-20-2020 05:55
Hi guys, I am trying to launch the companion when settings is changed. The following code does launch the companion but does not run "onchange". I require 'evt' object to compare new and old values. Please advise on how this is achievable.
settingsStorage.addEventListener("change", () => {})
settingsStorage.onchange = evt => {
if (evt.key.includes("a")) {
if (evt.newValue === evt.oldValue) {
// do something
return
}
if (evt.newValue !== null) {
// do something
}
}
}
Answered! Go to the Best Answer.
03-20-2020 12:56
03-20-2020 12:56
I don't think you can get onchange() if companion wasn't previously running. You have to handle that case using settings changed launch reason. I don't know of any easy way to tell which setting(s) changed; I usually assume all of them.
03-20-2020 12:56
03-20-2020 12:56
I don't think you can get onchange() if companion wasn't previously running. You have to handle that case using settings changed launch reason. I don't know of any easy way to tell which setting(s) changed; I usually assume all of them.
03-21-2020 23:41 - edited 03-21-2020 23:41
03-21-2020 23:41 - edited 03-21-2020 23:41
@Gondwana Yeah even I'll assume that all the settings have changed. Thank you!