Come si utilizza Meteor wrapAsync?Meteor wrap Sintassi asincrona
Qui di seguito è quello che sto cercando di fare
if (tempTreatment.groupId === undefined) {
// create new group
Meteor.wrapAsync(Meteor.call('createTreatmentGroup', salon, tempTreatment.groupName, tempTreatment.groupName));
// get group id
var getGroup = Meteor.wrapAsync(Meteor.call('getTreatmentGroup', salon, tempTreatment.groupName));
console.log(getGroup);
tempTreatment.groupId = getGroup._id;
}
voglio correre queste due funzioni Meteor.call
synchronosly ma ottengo undefined
su console.log(getGroup);
che shuold solo restituire un oggetto.
In 0.9.3 c'è [Meteor.wrapAsync] (http://docs.meteor.com/#meteor_wrapasync) che potrebbe essere utilizzato 'Ovunque'. Questo errore? –
Non l'avevo notato. Penso che abbiano creato una versione client di 'Meteor.wrapAsync' in modo che il codice che lo utilizza possa essere inserito nella cartella condivisa senza che si verifichino errori, ma in realtà è destinato all'uso del server. Nel caso in cui non sia fornita alcuna callback, la versione lato client di 'wrapAsync' definisce semplicemente un callback standard' logErr' da utilizzare, che registra semplicemente l'errore se presente: https://github.com/meteor/meteor/blob/ 9608e6205019b69a302cde62e21fcae1c7d22e3d/packages/meteora/helpers.js # L108 – saimeunt