Does a save on the python side trigger onEventSettingsUpdated callback in the js view model?


#1

@foosel may be the only one able to answer this question, but does anyone know if I make changes to a plugin's settings on the python side of OctoPrint and save does that trigger the onEventSettingsUpdated callback of the js/knockout view model or possibly are those changes instantly in-sync with the UI for knockout bindings to the settings view model?

Just trying to figure out if there are cleaner ways for me to program my plugins to update the UI side without the use of self._plugin_manager.send_plugin_message.


#2

Currently only when you save via the settings API. But thanks for the reminder, that's something I wanted to change.

In general, such questions are easy to answer with grep in the src/octoprint folder:

$ grep -rn "SETTINGS_UPDATED" *
events.py:120:  SETTINGS_UPDATED = "SettingsUpdated"
server/api/settings.py:556:     eventManager().fire(Events.SETTINGS_UPDATED, payload=payload)
server/__init__.py:315:         eventManager.subscribe(events.Events.SETTINGS_UPDATED, on_settings_update)

Or if you use something like PyCharm, it's even fancier, just right click on the event in events.py and select "Find Usages" (or hit Alt+F7)


#3

I always go to https://github.com/foosel/OctoPrint, enter SETTINGS_UPDATED in the search bar in the upper left, go with the default search scope, click the Code link to filter and I now have the collection of files. It might be slightly preferable since you have the reference in a small context which shows how's it's been used. It suffers from only showing you the first reference per file, though.