-
-
Notifications
You must be signed in to change notification settings - Fork 596
Proposal: The future of Parse.Promise #57
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 think the A+ error behavior is just better. So I support this migration |
Agreed. It was surprising to discover that the Parse JS SDK provides a promise implementation that does not behave the same way as virtually all other promise implementations for Javascript. Perhaps mentioning that the current version is not A+ compliant in the JS Guide someplace would be helpful. |
@TylerBrock Agreed! |
Is the I could give some help on that, because I am using async/await in my code, and it is really a pain to use wrap |
@RaitoBezarius I'm not sure I understand the question. The value of the flag can be retrieved by calling |
@andrewimm When you do |
1.6.9 has not been deployed to cloud code yet. It should be up shortly. |
@andrewimm Do you have a timeframe? Another question while I can, is |
It should be doable, since I believe Babel's transpile process works with any thenable (but I can sync up with Sebastian to double-check). If it doesn't, we'll make sure it's supported by 1.7.0. |
Thanks for those informations, @andrewimm ! I appreciate. :) |
I vote A+, really needing some exception handling right now |
FYI, I noticed that enabling A+ compliance for Parse Promises breaks at least one core piece of code in ParseReact: cf. parse-community/ParseReact#161. |
If we back Parse.Promise with native promises, then would we be able to use |
@JeremyPlease if you could guarantee that you clients all use the native promise and not a polyfill, then yes. But for all clients where we still add the custom implementation because |
@andrewimm Thanks for the quick response! Linting against missing handlers sounds like a great idea, but I don't see how this would work when returning promises that return and bubble up to a fail/error/catch handler in another file. If you have any suggestions on how linting would work for promises across files, please let me know. I'll try to take a look at ParsePromise.js to see what kind of effort there would be use native promises when available and polyfill as needed. |
What is the status of these? |
@JeremyPlease any chance you made progress on that? as it'S 2018, perhaps the promise library should be provided by a 3rd party no? |
The Parse JS SDK is built with babel transform runtime which will polyfill Promise. So, we should be able to use I just made a quick attempt to use native promises. Unfortunately, this breaks all kinds of tests and functionality that rely on ParsePromise resolutions to happen synchronously. The current ParsePromise implementation executes the promise callbacks immediately. However, native promises will execute the callbacks on "nextTick" (or a similar approach in browsers). So, tests like this one will fail with native promises since it expects the My recommendation: keep ParsePromise as-is. If there is a big want/need to switch to a native promise implementation I think it should be done as a v2 release. |
Thats, unfortunate and I guess it would introcude a lot of changes.
That's reasonable and would be very nice! |
This is unfortunate. However, as promises and async/await are slowly becoming ubiquitous, it will be beneficial for all to be standards compliant. I'm not sure how the synchronous resolution goes along the async/await code. I'm can help out in porting some of the code, if it is decided to go ahead in this direction. |
@agathver we’re not against refactoring the code to leverage native promises. As it’s been mentioned, many tests will have to be re-written and we can assist anyone wanting to tackle this task :) |
Yeah, definitely unfortunate. It might be good to have ParsePromise subclass Promise ( The biggest challenge will be modifying tests to properly handle asynchronous resolution of promises and then ensuring there isn't anything else in the Parse JS SDK or Parse Server that is unknowingly taking advantage of the current synchronous behavior. @agathver Please feel free to take a stab at this and post any updates here 😃 |
Team, is any work in progress on this? Thanks |
It seems that it doesn’t really need to be done at that time as no one is rushing for an implementation. Feel free to take a stab at it |
Closed via #620 As of 2.0 of this SDK Parse.Promise has been removed. |
This is a public discussion around the future of
Parse.Promise
. As Promises are made more widely available in browsers and Node, we need to consider evolving the currently implementation to meet developer expectations and avoid fragmentation.This document is simply a proposal, and is by no means a guarantee. We want to get developer feedback as we move the SDK forward, and we hope these discussion issues are a viable way to collect opinions on our proposals.
Parse.Promise today
Parse.Promise
was originally built off of the jQuery Deferred model years ago, which means it's almost – but not quite – Promises/A+ compliant. There are a few differences, but the only one that really affects developers involves the handling of exceptions: A+ will catch an exception, while the Deferred model will propagate it upwards.It turns out that
Parse.Promise
contains code to adapt to A+ semantics. Internally, we have a flag calledisAPlusCompliant
which is disabled by default (to maintain consistency with older versions). It's currently scoped within the module and inaccessible from userspace, but we could expose it through static methods or a CoreManager value. If we wish to moveParse.Promise
forward, this would be the first step.While this would bring Parse Promises in line with the Promises/A+ spec, they would not match the behavior of Promises found in JS. This is because the A+ spec only covers how Promises behave when resolved; it does not dictate how Promises are constructed, resolved, or rejected.
A Parse Promise can be constructed with no parameters, and can be resolved or rejected by any code, as the resolution is performed by instance methods:
Native JS Promises are constructed with a callback method. It is only within this method that the resolve / reject variables are available:
As such, code written for one format may be difficult to rewrite into the other format. We would like to add functionality to Parse.Promise, allowing it to be constructed using the native Promise API. Supporting both styles will maintain functionality with older codebases, but allow new developers to use Parse.Promise in a way that matches the native implementation.
Eventually, we would rewrite the internals of the SDK to match this new format. We would also modify Parse.Promise to be backed by native Promises where supported, and continue to use our polyfill when it is not available.
Proposed Timeline:
isAPlusCompliant
flag externally, either through methods or a CoreManager value.isAPlusCompliant
set to true. This behavior can be disabled for legacy purposes, but it will be the default for all future versions.new Promise(callback)
)new Promise(callback)
interface.The text was updated successfully, but these errors were encountered: