2017-08-01 81 views
0

當新用戶添加到用戶集合中時,雖然我可以在websocket中看到該html,但它不會重新渲染。當用戶添加到集合中時,流星不會重新渲染

websocket message

publication.js:

Meteor.publish('users.name.by-game', function(code) { 
    check(code, String); 
    this.autorun(function() { 
    const game = Game.findOne({ code }); 
    return Meteor.users.find(
     { _id: { $in: (game && game.getPlayersId()) || [] } }, 
     { fields: { 'services.gitlab.username': 1 } }, 
    ); 
    }); 
}); 

用戶線:

export default createContainer(({ code }) => { 
    const imagesHandle = Meteor.subscribe('images.all'); 
    const usersHandle = Meteor.subscribe('users.name.by-game', code); 
    const gameHandle = Meteor.subscribe('games.get-by-code', code); 
    const loading = !imagesHandle.ready() || !gameHandle.ready() || 
        !usersHandle.ready(); 
    const game = Game.findOne(); 
    return { loading, game }; 
}, GameRouterContainer); 

回答

0

你不需要this.autorun(function() {發佈函數內。

另外,如果問題是關於渲染的話,你粘貼的代碼不會讓我們幫你。

+0

在出版物中的自動運行需要觀察'遊戲'的變化,以便我們可以按照重新發布用戶。我們知道它是有效的,因爲沒有它,我們不會收到有關添加到客戶端的新用戶的消息。我們的問題是,消息確實到達客戶端後,它不會重新提交... –

+0

我沒有看到您的發佈函數返回任何值。 – Vincent

+0

這些出版物的工作 - 客戶收到相關數據。問題在於,當新用戶添加到遊戲中時,UI不會呈現。我們的發佈函數確實返回一個值,你可以看到我們在這裏使用的包 - https://atmospherejs.com/peerlibrary/reactive-publish –

相關問題