非同期関数が終了するのを待つためにクライアントmethod.callを取得する方法はありますか?現在、関数の終わりに達し、未定義を返します。MeteorJS非同期コード同期Meteor.methods関数
Client.js
Meteor.call('openSession', sid, function(err, res) {
// Return undefined undefined
console.log(err, res);
});
Server.js
Meteor.methods({
openSession: function(session_id) {
util.post('OpenSession', {session: session_id, reset: false }, function(err, res){
// return value here with callback?
session_key = res;
});
}
});
クライアントからの流星メソッドの中で非同期タスクを実行することはできないと思います。ファイバーを使用してサーバーではオプションになる可能性があります。 – Andreas