fflip icon indicating copy to clipboard operation
fflip copied to clipboard

Improve asynchronous failure handling

Open andreas opened this issue 5 years ago • 1 comments

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 😞

andreas avatar Aug 19 '20 14:08 andreas

Thanks for the suggestions @papandreou! 🙏

andreas avatar Sep 15 '20 07:09 andreas