Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get settings changed event obj when companion is launched by change in settings

ANSWERED

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
    }
  }
}

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
2 REPLIES 2

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.

Peter McLennan
Gondwana Software
Best Answer

@Gondwana Yeah even I'll assume that all the settings have changed. Thank you!

Best Answer
0 Votes