Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve asynchronous failure handling #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

andreas
Copy link
Contributor

@andreas andreas commented Aug 19, 2020

This PR improves upon #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 😞

lib/fflip.js Outdated Show resolved Hide resolved
test/fflip.js Outdated Show resolved Hide resolved
test/fflip.js Outdated Show resolved Hide resolved
@andreas
Copy link
Contributor Author

andreas commented Sep 15, 2020

Thanks for the suggestions @papandreou! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants