Publish not full reactive

Hey guys,
I’m having some trouble with a reactive publish method. I try to publish all “likes” with information about the user who liked me. This is my function:

Meteor.publish('likes', function () {


var gotLiked = Likes.find({user2: this.userId});
var allLikes = gotLiked.fetch();
likeArray = [];

_.each(allLikes, function (like) {
    likeArray.push(like.user1);
});

var users = Users.find({_id: {$in: likeArray}}, {
    fields: {
        'profile.picture': 1,
        'profile.gender': 1, 'profile.peerkey': 1
    }
});


return [users, Images.find({'owner': {$in: likeArray}}), gotLiked]

});

When someone likes me, I get a visual information in my template. But when I open it, there is only an empty div, meaning he doesn’t get the user information (gender and picture).

When I execute “Users.find().count()” in my browser console, I only get my own account. The funny thing is, if I reload the page and reopen the notification again, all information about the user that liked me are available.

Is the code above not fully reactive?

there are many topics on forum discussing join operations.
And yes, publish is not reactive the way how client side is.

Hi,
yes, I found “publish-composite” but it is still not working - even the reload doesn’t work anymore.

Meteor.publishComposite('likes', {

find: function () {
    return Likes.find({user2: this.userId});
},
children: [{

    find: function (like) {
        return Users.find(like.user1, {
            fields: {
                '_id':1,
                'profile':1,
                'profile.picture': 1,
                'profile.gender': 1, 'profile.peerkey': 1
            }
        });
    }, children: [{

        find: function (user) {
            return Images.find({owner: user._id});
        }
    }]
}]

});

user2 is the user that’ve been liked (me) and user1 contains the id of the user who liked. I get still like notifications, but they are empty. My helpers look like this:

Template.layout.helpers({
'likes': function () {
    return Likes.find({user2:Meteor.userId()});
},
'likeUser': function()
{
    return Meteor.users.findOne(this.user1);
}
});

Template:

<ul id='dropdown1' class='dropdown-content'>
{{#each likes like}}
<li class="item-user"><img class="preview-partner left"
         src=""/>
    <span>{{likeUser.profile.gender}}</span></li>
    {{/each}}


</ul>

If I replace this.user1 with this.user2 (my own account), I get the gender - means he doesn’t load the other users data.

Okay, it’s working now but I’m having another issue. I got some errors thrown:

Exception in template helper: .likePicture@http://localhost:3000/client/templates/application    /layout.js?c86738acdb30bf4f9fd5fce65fc5e2d1a50c3612:50:16
bindDataContext/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2880:14
Blaze._wrapCatchingExceptions/<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1651:14
wrapHelper/</<@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2928:14

It’s all about this:

<li class="item-user"><img class="preview-partner left"
         src="{{ likePicture }}"/>

Helper is:

'likePicture':  function()
{
    return Meteor.users.findOne(this.user1).profile.picture.url("images");
}

(I’m using CollectionFS - on my start template, it is working).

Where is this.user1 coming from?

It comes from the “Likes” Collection:

Router.route('/decide', {
name: 'decide',
waitOn: function() { return Meteor.subscribe('likes'); }
});

An example: {user1:‘abc’, user2:‘def’}
user1 is the user who liked, user2 the user who got that like.