-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support for error handling and promises #3
Conversation
This is a really great contribution! What do you mean by data consumers? You mean like gulp-swig and gulp-jade? So they can still depend on file.data being available as a regular object? |
Correct! |
Also, I see what you mean about the breaking change on the setup side now that it includes the err object as the first param. I'm not sure of the best way to handle that yet. |
Major version bump due to API difference; so people who specify gulp-data as a dependency (e.g. gulp-data: "~1.0.1") don't automatically have the new version kill all their stuff. You could type check the first object; |
yeah that's reasonable... the work you did justifies it being out of "beta" as it's really well rounded now. As it's a major contribution, would you mind updating the version as well as adding your self as a contributor in the package.json? Once that's committed I'll merge it in. Thanks! |
oh, can you also update the README with your examples? :-D |
… one more feature for returning objects in data function.
Done I think. Final feature: you can return the data object from the data function as well now. data(function(file) {
return { foo: 'bar' };
}); |
Very impressive, thanks for your help! |
Support for error handling and promises
No problem! Let me know when it's upstream in npm. |
All published... I assumed the |
nevermind, I guess it doesn't do that. I added the list to the README. Thanks again. |
Now you can have error handling in your callbacks (more in-line with standard node callbacks); you can also use promises in the same fashion gulp does which makes some patterns simpler. Appropriate tests have been added. Unfortunately this breaks previous data providers, but data consumers are not effected. Some examples of the new style follow.
Generate an error:
Return a successful result:
Use a promise from MongoDB:
Use a promise from MongoDB within the callback: