Fibers-agnostic context-handling wrapper? Has it been written yet?

When looking at some code that uses fibers directly, it seems there should exist a wrapper library that uses fibers for implementation when available and otherwise does whatever is the replacement that preserves the context for callbacks (asynclocalstorage?)

E.g. from picker/implementation.js at master · Meteor-Community-Packages/picker · GitHub

PickerImp.prototype._processRoute = function(callback, params, req, res, next) {
  if(Fiber.current) {
    doCall();
  } else {
    new Fiber(doCall).run();
  }

  function doCall () {
    callback.call(null, params, req, res, next); 
  }
};

How can this code be written in a fiber-agnostic way so that it works both in 2.8, 2.9 and 3.0?

1 Like

We’re already working on something in this line. You can check it here.

Are you modifying something and creating these wrappers?

2 Likes