这是另一个例子。
假设您正在编写宾果游戏,然后单击按钮以调用“ house!”。在单击事件中,您可能会调用Method,例如
Method.call("callHouse");这将调用服务器方法:
// on the server Meteor.methods({ callHouse: function () { if (currentGame.isInProgress) { currentGame.winner = this.userId; currentGame.end(); } } });if you are the first to call “house”, the method will mark you as the winner..
however, let’s pretend the method is extremely slow and your client app is
waiting.. you’re 99% sure the server will confirm you are the winner - you
just want to update the user’s screen without the wait.. in this case
implement a client-side stub:
// on the clientMeteor.methods({ callHouse: function () { currentGame.winner = Meteor.userId(); // add any other side-effects you expect to occur here }});when the server result returns, if the data returned is different to what you
set in the stub, it will correct it and refresh the screen accordingly.



