SpoturDeal / MMM-rain-forecast

Magic Mirror module
MIT License
9 stars 4 forks source link

Scope self locally to prevent global contamination #3

Closed mrvanes closed 5 years ago

mrvanes commented 5 years ago

It turned out the getData() of one of my other modules wasn't called anymore because we both use self to get the address of the getData() callback function. It turns out that, without var nodejs uses a globally scoped self and since your module was loaded later, it allways "won" the callBack function. Using var in both your and my module keeps the callbacks sane again.