Open Thom1729 opened 3 years ago
Do we want to ensure the decorator is only used on classes that subclass our SettingsListener classes or would that hinder mixin usage?
Can we even? I think at the time the decorator is called, the function hasn't been bound to the class yet, so that might be a moot point.
As seen on Discord. Motivating examples:
This would provide the same convenience features as
SettingsDict.subscribe
: selecting the desired value from the settings, detecting whether that value has changed, and keeping track of the previous value. What is also provides beyond that is automatic management of the subscription lifetime. Manually callingclear_on_change
is annoying, easy to forget, prone to mistakes, and when done right kind of boilerplate-y. ASettingsListener
class can handle this automatically by simply inheriting from the existing listener classes (that Sublime already manages), callingclear_on_change
in__del__
, and using a weakref inadd_on_change
.