Created
February 17, 2017 12:35
-
-
Save iendjinn/62e812cefff5c69a3aa4440e257d93d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// estimator.js | |
module.exports = (function() { | |
var getData = function(id, cb) { | |
api.getData(id, this.state.filter, (err, response) => { | |
if (err) { | |
cb(err); | |
} else { | |
cb(null, response.data); | |
} | |
}); | |
} | |
function estimator(initial) { | |
this.state = initial; | |
this.getData = getData; | |
} | |
return estimator; | |
}()); | |
// Databot.js | |
var Promise = require("bluebird"); | |
var Estimator = Promise.promisifyAll(require("./estimator.js")); | |
var estimator = new Estimator(initial); | |
estimator.getDataAsync(id).then((data) => { | |
console.log(data); | |
}).catch((err) => { | |
console.log(err); | |
});; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment