How to run code outside of meteor method simulation
<p>I've got a very interesting issue in my Meteor js app: when I call a meteor method inside of my template's onCreated method the callback for that method call sometimes returns immediately with undefined as the result. It turns out that this is because the template got created as a result of running a meteor method simulation.</p>

<p>Two questions:</p>

<ol>
<li>Is is this a bug? It certainly isn't the behavior that I expected.</li>
<li>How can I work around this without using weird hacks like setTimeout (and, by the way <code>Meteor.setTimeout</code> isn't allowed inside of method simulations)?</li>
</ol>

<p>Some Code:</p>

<pre><code>// My Template (Not my real code, just to demonstrate)
Template.saying.onCreated(() =&gt; {
  var tmpl = Template.instance();
  tmpl.saying = new ReactiveVar();

  Meteor.call('getSaying', (err, saying) =&gt; {
    // If called inside of a simulation, saying is null
    tmpl.saying.set(saying);
  });
});


// Assume that the above template is used in an {{each}} block
// and somewhere in my code I call this
Items.insert({});

// Because Items.insert wraps a meteor method which also runs as a
// simulation on the client, then the Template.saying.onCreated
// callback will be called in the context of an active simulation,
// which means that 'getSaying' method call will return immediately
// with undefined as the result.
</code></pre>