Hey guys,
I’m using Iron Router’s waitOn
to wait until my subscription is ready. This is my code:
Router.route('/me', {
name: 'me',
data: function() { return Meteor.user(); },
waitOn: function() { return Meteor.subscribe('myPictures'); }
});
Now I’m initializing in my template some jQuery plugins, to show a photo browser:
Template.myPictured.onRendered(function() {
myImages = Images.find({owner: Meteor.userId()}).fetch();
console.log(myImages.length);
initPlugin(myImages);
});
My problem: I get an empty array. If I execute the commands with a timeout of 1 second, it works fine. Why is the data of the subscription not available although I wait until the subscription is ready?
//Edit: I see that’s an CollectionFS issue. When I do the find()
in my onRendered method, the Images objects aren’t transformed and my field owner
isn’t available. If I wait 1 seconds, all Image object are transformed and my field owner
is available. Is there an event when transformation has finished?