Meteor events should be more extensible

One problem I run into a decent amount is an inability to create reactive events that extend from Template.[template].events({}). For example, I might want to do something like this:

Template.orderList.events({
  'scroll .ion-content': _.throttle(function() {
    // some code here to create an infinite scrolling effect.
  }, 300),
  'resize': _.throttle(function() {
    // change around display in some way or another.
  }, 200)
});

It seems like the maps have a very specific set of events you can use. Ideally, this would be more extensible to add in some keyed events. Eg:

_.extend(Template.events, {
  'resize': function() {
    window.addEventListener('resize', function() {
      // fire template event
    })
  }
});

Is it possible to extend these events?

2 Likes

In this case, when would the resize event be triggered?

You could set those events up using jquery and track them within a reactive variable, add dependencies to that variable for when you want to trigger an action.

Not the cleanest of solutions, but has worked for me so far.