gpt4 book ai didi

meteor 订阅回调

转载 作者:行者123 更新时间:2023-12-03 10:31:17 24 4
gpt4 key购买 nike

根据这里的这篇文章:

https://dweldon.silvrback.com/common-mistakes

Subscriptions don't block

Many aspects of the framework seem like magic. So much so that it may cause you to forget how web browsers work. Take this simple example:

Meteor.subscribe('posts');

var post = Posts.findOne();

The idea that post will be undefined is the root cause of roughly one in twenty meteor questions on stackoverflow.



那么为什么订阅没有回调,如果有,为什么 meteor 文人没有更频繁地引用它?

为什么我们没有:
Meteor.subscribe('posts', function(err, posts){

//when the items/posts actually arrive

});

我希望我的问题是有道理的。

最佳答案

也许我没明白这个问题,但 Meteor.Subscribe 函数有名为 onError 和 onReady 方法的回调。

Optional. May include onError and onReady callbacks. If a function is passed instead of an object, it is interpreted as an onReady callback.



From docs.

例如。
Meteor.subscribe("posts", {
onReady: function () { console.log("onReady And the Items actually Arrive", arguments); },
onError: function () { console.log("onError", arguments); }
});

另请检查此 GitHub issue

关于 meteor 订阅回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28621132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com