Cordova onResume event

Where/how do I implement the following cordova event handler in MeteorJS?

document.addEventListener('resume', function () {
    setTimeout(function () {
    }, 0);
}, false);

That’s how you do it. There’s nothing special in meteor for this. You could wrap this in Meteor.isCordova check but that’s not even necessary.

Meteor.startup(function () {
if ( Meteor.isCordova ) {

document.addEventListener('resume', function () {
  setTimeout(function () {
  }, 0);
}, false);


Side note, wouldn’t it be cool if templates had listeners like events and helpers? Maybe not too beneficial but for some projects I feel it’s missing

Thanks for the replies. It actually did work, it was an issue with refreshing my cordova app on android - not with the onresume event.

better describe, are not these template events exactly that ?

Yes, you are correct. But say you want to listen to an audio-element, then you can’t use events for that

I still dont get why you would not be able to use them.

Could I for this:

player = document.getElementById("podcastPlayer");
player.addEventListener("timeupdate", function() {

Do maybe

'timeupdate #podcastplayer': function() {

If so, thank you, I had no clue really, this would solve so much

Try it, you used syntax the correct way. How I would access any other event in template.

Wow, that worked. Thank you, you really do learn something everyday, cheers!

Kinda wierd diff from git though

Hi, add the event listener works well… but how do I remove it in the Template onDestroyed… ie I don’t want the app firing this event each time it resumes… only for a specific template?

I see but the issue with that is the onResume function has lost the context, if outside of the onRendered/onDestroyed.

Update: ok I followed the subcomment and declared an empty function and overwrite it, as per

post is called whenever anything on the page wants to interact with the player. In this place it’s called by the intializePlayer function not seen. Your answer was correct, though. Although I was attaching an external function to the EventListener, I was defining that function inside of Template.onCreated, meaning Template.onDestroyed didn’t have access to it. The solution was to declare an empty function in the top level var viewMessageReceived = function(event) { } and then redefine that function inside Template.onCreated where I have access to the template through this. – RevMen Feb 4 '16 at 16:38

So seems like a hack… not sure if better way to do this?