观察变化时,Meteor不会更新记录

时间:2015-11-01 09:42:08

标签: angularjs meteor ionic-framework ionic

我有这段代码,我在那里收听新添加的项目到集合中。收到某件商品后,我想立即更新,并将其标记为received。初始状态为queued

    var invites = Invites.find( {} );

    //  Watch for new invites
    invites.observeChanges( {
        added  : function ( id, invite ) {
            Invites.update( invite._id, {
                $set: {
                    status: 'received'
                }
            }, function ( error, affected_rows ) {
                console.log( error, affected_rows );// prints undefined
            } );
        }
    } );

问题是状态永远不会改变。如果我刷新页面,状态将切换到received,因此它在某种程度上仍然停留在过程中。

我甚至尝试通过远程方法调用更新服务器端而没有任何运气。

顺便说一下,这是一个使用流星,角度,离子的移动应用程序。

1 个答案:

答案 0 :(得分:1)

我会自己回答。在使用observe块发送方法调用或更新之前,需要调用setTimeout。有关讨论,请参阅此问题:

https://github.com/meteor/meteor/issues/907

相关问题