Make function accessible to all templates within local packages

I have a plain ole’ client-side function like

function toggleLeftMenu(openClose){
if(openClose == 'open'){
    openLeftMenu()
}
else {
    closeLeftMenu()
}
}

It lives in my masterLayout template.

I want to be able to call it from any Template.event function, including ones that live inside of my local /packages.

I’ve used Meteor.call() client-side, and that does the trick and the event works. However, it still logs a 404 in the console.

What is the proper way to have a public scoped or application scoped function accessible everywhere?

Thanks,
Don

You could rewrite it as:

toggleLeftMenu = function (openClose){
  if(openClose == 'open'){
    openLeftMenu()
  }
  else {
    closeLeftMenu() 
  }
}

If this is somewhere within the app, it is global. If it is within a package, then you need to export it from within package.js.

If you had put var before toggleLeftMenu it would then have been scoped local to that specific javascript file.

@serkandurusoy ,
Thanks! I was missing the export from the package.

Appreciate the help!

Don