percolatestudio/meteor-famous-demos

upgrading to meteor 0.8 breaks the demo

Opened this issue · 1 comments

upgrading to Meteor 0.8 inside one of the demos caused a crash

Uncaught TypeError: Object #<Object> has no method 'render' basics.js?5fc842552d4bd705257a70a1d7084fc5f5cbc813:49

Are you releasing an update with the latest Famous dist too?

With some modifications, a similar integration style as shown in this repo can still work with Meteor 0.8.0+, although the workaround does feel like a bit of a hack.

Background: According to the notes on Using Blaze, Meteor.render was removed, but a similar effect can be achieved with a line like UI.insert(UI.render(Template.foo), document.body). This is the new “manual” way of adding a reactive template to the DOM.

So to complete our integration with Famo.us, we need to create a wrapper element, insert our Meteor template into it, and then attach that wrapper to our Famo.us surface using the content option. Like this:

var div = document.createElement('div');
UI.insert(UI.render(Template.foo), div);
var surface = new Surface({
  size: [123, 456],
  content: div
});

In a few simple test examples I’ve put together, this approach works — preserving Meteor’s reactivity and allowing for Famo.us behaviors such as transforms. (It also appears to be the essential approach used in other Meteor/Famo.us integrations such as gadicc/meteor-famous-components.) Take heed, though: This suggestion comes with a spoonful of YMMV.