-
-
Notifications
You must be signed in to change notification settings - Fork 595
Proposal: Deprecate Backbone-style callbacks #56
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
Comments
i favor deprecating backbone style callbacks. i even created eslint rule for it. but i think total remove should be in |
i have a thought about after deprecation of the it's a breaking change, but it might be more opinionated and strict and may let for a fewer errors: // success
Parse.Cloud.define('ƒ', function(request) {
return {
"data": {···}
};
});
// success
Parse.Cloud.define('ƒ', function(request) {
return Promise.resolve(···);
});
// error
Parse.Cloud.define('ƒ', function(request) {
throw new Error(···);
});
// error
Parse.Cloud.define('ƒ', function(request) {
return Promise.reject(···);
});
// maybe error for undefined?
Parse.Cloud.define('ƒ', function(request) {}); also in the future when Parse.Cloud.define('ƒ', async function() {
const data = await ···;
···
return ···;
}); |
Yeah, I think allowing cloud function to return promises would be an improvement. Would it even be a breaking change?... we could do something tricksy like behaving differently based on whether your function has one or two args. I think there's precedent for doing stuff like that in some node libraries. |
@lacker yep. my mistake. i forgot about i think this thing can be improve for unit testing of the server side and also for deciding when to terminate the process of the function. also this pattern can be applied to other Cloud Code APIs as the thing i'm not sure of is the error part. for promises it's better to use a native |
It's too bad that ParseError can't just extend Error. It seems like the promises shouldn't convert anything from one type to another. AFAICT the promise spec doesn't specify Error or anything, the promise spec just specifies that when something goes into "reject" or is thrown, it gets passed along like an error. Promises should work just as well if you just throw a string for example. I could be wrong there. |
@lacker it's true, but it will be a very weird behave for JavaScript developers to |
Hmm, well so how about: That seems logical to me. |
Closed via #620 As of 2.0 of this SDK Backbone-style callbacks have been removed. |
For legacy reasons, the SDK currently supports handling asynchronous actions through two separate methods: Backbone-style success/error callbacks, and Promises. We would like to explore the idea of deprecating the callbacks interface in favor of only using Promises, and we would like community input on this decision.
Why deprecate this piece of the SDK?
We believe that the callbacks format is a less-than-optimal approach to structuring asynchronous code. With ES6, Promises are a feature of the JS language, and we want to discourage async formats that allow developers to fall into "callback hell."
From a code perspective, these require internal methods to have a bunch of boilerplate in order to support wrapping controller methods that use Promises. Removing these callbacks would reduce complexity and remove bytes from nearly every publicly-exposed method.
Proposed deprecation path:
In 1.7.0, using Backbone callbacks will log a warning that the format is now deprecated, and will be removed in 1.8. These warning will only be in the non-minified SDK, so they will not affect production.
In 1.8.0, we completely remove callbacks support.
The text was updated successfully, but these errors were encountered: