I want to make use of Fameo.us with Meteor.
- About Meteor I am interested in the very easy reactivity supplied by it, only by template variables and template helpers mentioning cursors.
- About Famo.us I am interested in the performant gui supplied by it.
Question A: Is it possible to achieve the **reactivity in 1. by vanilla Fameo.us Surfaces and Layouts and supply their content
with just Meteor cursors?**
Briefly like:
//Announcements, a Meteor Mongo reactive data source
Annos = new Mongo.Collection('annos');
//surface, a Famo.us Surface.
var surface = new Surface({
content: Annos.find()//a Meteor cursor
})
UPDATE:
I now use a cursor.observe()
to detect changes on data source and take callback actions provided by .observe()
, like addedAt
, changedAt
. This callbacks creates or updates Surfaces with added or changed data in data source.
But I see only [object Object]
in my created surfaces on the browser screen. When I use just doc.key
instead of the Blaze function below, I can see the data as desired. But this leaves me put Meteor Templates away with its event maps, and easy template syntax.
Question B: What should I do to take the return from Blaze render in HTML string format?
Question C: How can I use Meteor events for Meteor Templates in this different approach? For now it does not work if I use Template.myTemplate.events({events map})
.
fragment of my code related to the issue is:
//For Reactivity
cursorToArray = function(cursor, renderables, createFn){
cursor.observe({
addedAt: function(document, atIndex, before) {
renderables.splice(atIndex, 0, createFn(document));
},
changedAt: function(newDocument, oldDocument, atIndex) {
//there was a note on this on the github,
//look outdated oldest repo for if reactiveSurface defined there too.
renderables[atIndex] = createFn(newDocument);
}
});
}
cursorToArray(Ilans.find(), ilansSurfaces, createSurface);
var ilansSurfaces = [];
function createSurface(doc) {
var surface = new Surface({
size: [undefined, 100],
//content: doc.key
content: Blaze.renderWithData(Template.ilanTemplate, doc)
});
surface.pipe(scrollview);
return surface;
}
my template is:
<head>
<title>Meteor + Famous Playground</title>
<!-- Blatanly stolen Meteor favicon. -->
<meta name="viewport" content="width=device-width, maximum-scale=1, user-scalable=no" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
</head>
<body>
</body>
<template name="ilanTemplate">
<p>{{key}}</p>
</template>