Meteor Capture

Blaze Updates

A quick rundown of some new features coming to Blaze.

Next Release

New template callbacks

Template.foo.onCreated(function() {  
});

Template.foo.onRendered(function() {  
});

Template.foo.onDestroyed(function() {  
});

Template level subscriptions

New template instance methods
subscribe and subscriptionsReady

Template.foo.onCreated(function() {  
  this.subscribe('foo');
  this.subscribe('bar');
});

A new template helper Template.subscriptionsReady

<template name="foo">  
  {{#if Template.subscriptionsReady}}
    Good things in here
  {{else}}
    Loading...
  {{/if}}
</template>  

Coming soon

Template 'state' ReactiveDict

Template.instance().state

https://github.com/meteor/meteor/pull/3561

Here's the default Meteor application converted to make use of the new Template instance state ReactiveDict.

Template.hello.onCreated(function() {  
  // counter starts at 0
  this.state.set('counter', 0);
});

Template.hello.helpers({  
  counter: function() {
    return Template.instance().state.get('counter');
  }
});

Template.hello.events({  
  'click button': function(event, template) {
    // increment the counter when button is clicked
    template.state.set('counter', template.state.get('counter') + 1);
  }
});

#each .. in ..

https://github.com/meteor/meteor/pull/3560

<ul>  
{{#each person in people}}
  <li>{{person.name}} from {{people.groupName}}</li>
{{/each}}
</ul>

{{#each people}}
  [email protected]}}
{{/each}}

{{#let x=y.z f=w.s}}
  {{x}} {{f}} {{w}}
{{/let}}

Example from Slava's pull request


Sashko's "Proposal for Blaze 2" hackpad

Worth checking out, there's currently a load of ideas and discussion going on surrounding potential future changes to Blaze.
https://meteor.hackpad.com/Proposal-for-Blaze-2-bRAxvfDzCVv

Also see Upcoming features in Meteor Blaze.


If I've missed anything, please let me know in the comments below!

comments powered by Disqus