1
Meteor非同期メソッド内にコールバック関数を設定して、「読み取り可能な」イベントで呼び出すようにしました。しかし、コールバックはon "readable"が起動しているときにコールされていません(私が設定したconsole.logから起動していることがわかります)。Meteor jsコールバックが動作しない
ここに何か不足していますか?私はいくつかの異なることを試して、数時間それを行ってきました!
Meteor.startup(() => {
Meteor.call("getfeed", function(feedloader) {
//I get: TypeError: undefined is not a function]
console.log(feedloader);
});
});
Meteor.methods({
getfeed: function(callb) {
var req = request('http://feeds.feedburner.com/Techcrunch');
var feedparser = new FeedParser();
testing = [];
//........a bunch of functions........
feedparser.on('readable', function() {
var stream = this
, meta = this.meta
, item;
while (item = stream.read())
{
//I'm pushing the results into testing var
testing.push(item);
}
//From the logs I can see that this is called 12 times
//but the callback's not firing!!!
console.log(testing.length);
callb(testing);
});
}
});
こんにちは、私は '終わり'のイベントを持っていないということです。 '読み取り可能な'イベントはここで繰り返し止められるまで呼び出され、いつ停止するかわかりません!変数と同期して 'testing'変数を保持できる方法はありますか? – jaisonDavis
申し訳ありませんが悪いです。終了イベントがあります。それを逃した! – jaisonDavis
そして、それは返される必要がありますラップ();単にwrapped()の代わりに。 – jaisonDavis