Skip to content

Instantly share code, notes, and snippets.

@mridgway
Created February 3, 2015 07:45
Show Gist options
  • Save mridgway/5abc46a3c76214e8470c to your computer and use it in GitHub Desktop.
Save mridgway/5abc46a3c76214e8470c to your computer and use it in GitHub Desktop.
'use strict';
var bluebird = require('bluebird');
module.exports = function promisifyPlugin(options) {
options = options || {};
/**
* @class PromisifyPlugin
*/
return {
name: 'PromisifyPlugin',
/**
* Called to plug the FluxContext
* @method plugContext
* @returns {Object}
*/
plugContext: function plugContext() {
return {
/**
* Provides full access to the router in the action context
* @param {Object} actionContext
*/
plugActionContext: function plugActionContext(actionContext) {
actionContext.executeAction = bluebird.promisify(actionContext.executeAction);
},
/**
* Provides access to create paths by name
* @param {Object} componentContext
*/
plugComponentContext: function plugComponentContext(componentContext) {
componentContext.executeAction = bluebird.promisify(componentContext.executeAction);
}
};
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment