1
Meteor 비동기 메소드에서 "읽을 수있는"이벤트에서 콜백 함수를 호출하도록 설정했습니다. 그러나 콜백은 "읽기 가능"상태에서 시작될 때 호출되지 않습니다 (나는 콘솔에서 해고된다는 것을 알고 있습니다. 설정 한 로그).Meteor js 콜백이 작동하지 않습니다.
여기에 뭔가가 있습니까? 나는 2,3 시간 동안 지금 그것에 다른 약간의 물건을 시험해보고 있었다!
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