A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
Read the statement by Michael Teeuw here.
SocketNotification not working?
-
This post is deleted! -
@tjat said in SocketNotification not working?:
this.sendSocketNotification
what does the ‘this’ point to ? to module helper instance or something else?
-
@sdetweil - It’s within the main module we’re I’m creating the calendar event. I’m following the same syntax being used above, which is working. I’ll also caveat that I’m not really experienced with this stuff so likely am doing something dumb. Am I losing the “this” reference somehow? Appreciate the help
this.sendSocketNotification("ADD_CALENDAR_EVENT", payload); this.message = "Adding event..."; this.messageType = "info"; this.updateDom(); this.closeForm(); }, notificationReceived: function(notification, payload, sender) { // TODO: Handle notifications }, socketNotificationReceived: function(notification, payload) { if (notification === "EVENT_ADD_SUCCESS_MAIN") { console.log ("Sending event to calendar"); this.showMessage('Event added!', 'success'); if (payload) { this.sendNotification("EVENT_ADD_SUCCESS", payload); } else { this.sendNotification("EVENT_ADD_SUCCESS"); } } else if (notification === 'EVENT_ADD_FAILED') { this.showMessage('Event not added', 'error'); if (payload) { this.sendNotification("EVENT_ADD_FAILED", payload); } else { this.sendNotification("EVENT_ADD_FAILED"); } } },
-
@tjat
Could you share the whole code in Git Hub? -
@tjat
If your calendar object is defined in anamed
function,this
will indicate the function itself. However in that case,sendSocketNotification
would cause an undefined function error.