fflip
fflip copied to clipboard
Improve asynchronous failure handling
This PR improves upon https://github.com/FredKSchott/fflip/pull/20 by adding better handling of asynchronous failures. As an example, we use asynchronous features loading to query our database, which can error. Currently we don't have a way to catch and handle those failures.
This PR updates the callback-function for config and reload, such that it accepts two arguments: err and data. This means that it conforms to the common error-first callback style, i.e. taking a (err, value) => ... function. Further, it means that you can easily promisify the two functions as follows:
const util = require('util');
const promisifiedReload = util.promisify(fflip.reload);
const promisifiedConfig = util.promisify(fflip.config);
Note that this is a breaking change 😞
Thanks for the suggestions @papandreou! 🙏