You need to sign in to do that
Don't have an account?
Jugbeer Bhola
Named Function inside Lightning Component
Working in a lightning component and have added a window.addEventListener. Have been told that is a memory leak and should add a removeEventListener also. To do that I cannot have an annonymous function. Could someone please explain how I could create a named function that passes all the necessary objects like component and event and use it inside the LEX component?
doInit : function(component,event,helper) { var action = component.get("c.getRoutine"); action.setCallback(this, function(response) { var state = response.getState(); if(state == "SUCCESS") { var responseWrapper = response.getReturnValue(); window.addEventListener('message', function(event) { var message = event.data; component.set("v.savedMessage",message.data); }, false); } });
Controller
Helper