unregister onResume event listener

unregister onResume event listener

  

Hi,

We have a mobile app and we have set an onResume event listener.

document.addEventListener("resume", function onResume() {
    // Handle the resume event
    $actions.LayoutOnPullToRefresh();
}, false);


Navigating from the screen gave errors on console suggesting using onDestroy event.

So I've put JS node with script "document.removeEventListener("resume", onResume, false);" onDestroy event but now I have Cant find variable: onResume error. 

What is a proper way to handle listeners in mobile app?

Hi Mykola,

Try this:

create local variable type object on your screen called onResumeFunc and also one as output parameter on your javascript node:

function onResume() {
    // Handle the resume event
    $actions.LayoutOnPullToRefresh();
};

$parameters.onResumeFunc = onResume;

document.addEventListener("resume", onResume, false);

After the javascript node set the local screen variable with the output parameter of your javascript node.

The local screen variable you pass into the javascript node for the OnDestroy as input parameter.

document.removeEventListener("resume", $parameters.onResumeFunc, false);

Regards,

Daniel

Hi Mykola,

Just wondering where you able to solve your problem?

Regards,

Daniel