daitj / gnome-display-brightness-ddcutil

Display brightness slider for gnome shell using ddcutil backend
GNU General Public License v3.0
294 stars 36 forks source link

fix #129: bind class method #133

Closed arty-name closed 5 months ago

arty-name commented 5 months ago

I have also noticed the error reported in #129 and figured out that the class method passed as a callback loses this reference, so it has to be bound

arty-name commented 5 months ago

An alternative solution would be to pass in an arrow function, since they capture this in closure:


            change: Main.layoutManager.connect('monitors-changed', () => {
              this.onMonitorChange();
            }),
daitj commented 5 months ago

bind is good enough for now, whole code base could move towards better structuring and ES6 but here we are.