I've developed a package for Meteor where I'm including another JavaScript Library (Ziggeo) by appending their scripts to the HTML head.
Here's the source https://github.com/Goltfisch/meteor-ziggeo/blob/master/ziggeo.js
I sometimes get an error that ZiggeoApi
is not defined if I want to call it from within my Meteor app which uses the package.
It seems that ZiggeoApi
is sometimes loaded a little bit slower so that it's not immediately available to the client.
How can I wait on the client until the ZiggeoApi
function is available?
I've tested stuff like
Tracker.autorun ->
if ZiggeoApi?
console.log 'ZiggeoApi is ready'
or put it in Template.foo.onRendered / Template.foo.onCreated
but it doesn't work.
Thanks in advance!
Here's a dirty solution, check regularly that the API is present: