Migrate Meteor.wrapAsync

This commit is contained in:
Sashko Stubailo
2014-09-05 18:47:58 -07:00
parent 6f829b32a9
commit 0772306c2d
5 changed files with 12 additions and 4 deletions

View File

@@ -44,7 +44,7 @@ followed by your application code.
});
}
{{> api_box wrapAsync}}
{{> autoApiBox "Meteor.wrapAsync"}}
{{> autoApiBox "Meteor.absoluteUrl"}}

File diff suppressed because one or more lines are too long

View File

@@ -68,7 +68,7 @@ nameToId = {
"Accounts.ui.config": "accounts_ui_config",
"Meteor.settings": "meteor_settings",
"undefined": "meteorpublishforarch",
"Meteor.wrapAsync": "meteor_wrapAsync",
"Meteor.wrapAsync": "meteor_wrapasync",
"Meteor.absoluteUrl": "meteor_absoluteurl",
"Meteor.release": "meteor_release",
"Subscription#onStop": "publish_onstop",

View File

@@ -98,6 +98,7 @@
"Meteor.user",
"Meteor.userId",
"Meteor.users",
"Meteor.wrapAsync",
"MethodInvocation",
"MethodInvocation#connection",
"MethodInvocation#isSimulation",

View File

@@ -78,7 +78,14 @@ _.extend(Meteor, {
// fs.open(pathname, flags, [mode], [callback])
// For maximum effectiveness and least confusion, wrapAsync should be used on
// functions where the callback is the only argument of type Function.
//
/**
* @memberOf Meteor
* @summary Wrap a function that takes a callback function as its final parameter so that the wrapper function can be used either synchronously (without passing a callback) or asynchronously (when a callback is passed). If a callback is provided, the environment captured when the original function was called will be restored in the callback.
* @locus Anywhere
* @param {Function} func A function that takes a callback as its final parameter
* @param {Object} [context] Optional `this` object against which the original function will be invoked
*/
wrapAsync: function (fn, context) {
return function (/* arguments */) {
var self = context || this;