Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: capture "this" for the closure's scope #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions MMM-GoogleTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ Module.register("MMM-GoogleTasks", {
if (notification === "SERVICE_READY") {
this.sendSocketNotification("REQUEST_UPDATE", this.config);

// Create repeating call to node_helper get list
// Create repeating call to node_helper get list.
// Must make a helper variable to capture "this" at the right scope.
// See https://github.com/MichMich/MagicMirror/issues/196#issuecomment-211565531
const self = this;
setInterval(function () {
this.sendSocketNotification("REQUEST_UPDATE", this.config);
}, this.config.updateInterval);
self.sendSocketNotification("REQUEST_UPDATE", self.config);
}, self.config.updateInterval);

// Check if payload id matches module id
} else if (
Expand Down