在一個函數,它已經內Meteor.binEnvironment,當我運行<collection>.find ({})
,我得到的錯誤throw new Error ('Can \' t wait without a fiber ');
如果你把該呼叫也內Meteor.bindEnvironment(<collection>.find ({}))
,錯誤消息變成:throw new Error (noFiberMessage);
Meteor.Collection與Meteor.bindEnvironment
有問題的功能通過Meteor.methods ({})
我哪裏錯了?
實施例重現該錯誤:
Meteor.methods({
"teste" : Meteor.bindEnvironment(function(){
var Future = Meteor.require('fibers/future');
var future = new Future();
setTimeout(function(){
return future.return(Sessions.findOne({}))
}, 15000);
console.log('fut', future.wait());
})
});
我不知道是否能解決您的實際問題,但在你的例子,沒有必要使用'流星.bindEnvironment',只需使用'Meteor.setTimeout'而不是'setTimeout'('Meteor.setTimeout'將爲你使用'Meteor.bindEnvironment')。 –