meteorWrapping asynchronous methods into a Fiber for synchronous execution.


Syntax

  1. Meteor.wrapAsync(func, [context])

Parameters

ParametersDetails
func: FunctionAn asynchronous/synchronous function to be wrapped in a Fiber that takes a callback w/ parameters (error, result).
context: Any (optional)A data context in which the function gets executed upon.

Remarks

An asynchronously wrapped function may still be ran asynchronously if a callback with parameters (error, result) => {} is given as a parameter to the wrapped function.

The incorporation of Meteor.wrapAsync allows for code ridden with callbacks to be simplified given that callbacks can now be neglected in compensation for making the call block its present Fiber.

To understand how Fibers work, read here: https://www.npmjs.com/package/fibers.