使用 ReactiveVar

伺服器端

Meteor.methods({
  getData() {
    return 'Hello, world!';
  }
});

客戶端

<template name="someData">
  {{#if someData}}
    <p>{{someData}}</p>
  {{else}}
    <p>Loading...</p>
  {{/if}}
</template>
Template.someData.onCreated(function() {

  this.someData = new ReactiveVar();

  Meteor.call('getData', (err, res) => {
    this.someData.set(res);
  });
});

Template.someData.helpers({
  someData: function() {
    return Template.instance().someData.get();
  }
});

需要 reactive-var 包。要新增它,請執行 meteor add reactive-var