{"action":"created","issue":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/57","labels_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/57/comments","events_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/57/events","html_url":"https://github.com/ParsePlatform/Parse-SDK-JS/issues/57","id":111513063,"number":57,"title":"Proposal: The future of Parse.Promise","user":{"login":"andrewimm","id":494043,"avatar_url":"https://avatars.githubusercontent.com/u/494043?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewimm","html_url":"https://github.com/andrewimm","followers_url":"https://api.github.com/users/andrewimm/followers","following_url":"https://api.github.com/users/andrewimm/following{/other_user}","gists_url":"https://api.github.com/users/andrewimm/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewimm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewimm/subscriptions","organizations_url":"https://api.github.com/users/andrewimm/orgs","repos_url":"https://api.github.com/users/andrewimm/repos","events_url":"https://api.github.com/users/andrewimm/events{/privacy}","received_events_url":"https://api.github.com/users/andrewimm/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/labels/discussion","name":"discussion","color":"eeeeee"},{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/labels/proposal","name":"proposal","color":"5319e7"}],"state":"open","locked":false,"assignee":{"login":"andrewimm","id":494043,"avatar_url":"https://avatars.githubusercontent.com/u/494043?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewimm","html_url":"https://github.com/andrewimm","followers_url":"https://api.github.com/users/andrewimm/followers","following_url":"https://api.github.com/users/andrewimm/following{/other_user}","gists_url":"https://api.github.com/users/andrewimm/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewimm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewimm/subscriptions","organizations_url":"https://api.github.com/users/andrewimm/orgs","repos_url":"https://api.github.com/users/andrewimm/repos","events_url":"https://api.github.com/users/andrewimm/events{/privacy}","received_events_url":"https://api.github.com/users/andrewimm/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2015-10-14T23:10:41Z","updated_at":"2015-12-08T20:02:39Z","closed_at":null,"body":"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.\r\n\r\nThis 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.\r\n\r\n### Parse.Promise today\r\n`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.\r\n\r\nIt turns out that `Parse.Promise` contains code to adapt to A+ semantics. Internally, we have a flag called `isAPlusCompliant` 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 move `Parse.Promise` forward, this would be the first step.\r\n\r\nWhile 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.\r\nA 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:\r\n```js\r\nlet myPromise = new Parse.Promise();\r\n// do something...\r\nmyPromise.resolve();\r\n```\r\nNative JS Promises are constructed with a callback method. It is only within this method that the resolve / reject variables are available:\r\n```js\r\nlet myPromise = new Promise((resolve, reject) => {\r\n  // do something...\r\n  resolve();\r\n});\r\n```\r\nAs 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.\r\n\r\nEventually, 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.\r\n\r\n### Proposed Timeline:\r\n- [x] Before 1.7, expose the `isAPlusCompliant` flag externally, either through methods or a CoreManager value.\r\n- [ ] In 1.7.0, default to having `isAPlusCompliant` set to true. This behavior can be disabled for legacy purposes, but it will be the default for all future versions.\r\n- [ ] Additionally in 1.7.0, allow Parse.Promise to be constructed in the same way as native Promises (`new Promise(callback)`)\r\n- [ ] In 1.8.0, let Parse.Promise be backed by native promises where supported; continue to polyfill methods in environments that don't include a native Promise implementation\r\n- [ ] In 1.8.0, rewrite the internals of the SDK to use the `new Promise(callback)` interface.\r\n"},"comment":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/comments/162998478","html_url":"https://github.com/ParsePlatform/Parse-SDK-JS/issues/57#issuecomment-162998478","issue_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/57","id":162998478,"user":{"login":"andrewimm","id":494043,"avatar_url":"https://avatars.githubusercontent.com/u/494043?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewimm","html_url":"https://github.com/andrewimm","followers_url":"https://api.github.com/users/andrewimm/followers","following_url":"https://api.github.com/users/andrewimm/following{/other_user}","gists_url":"https://api.github.com/users/andrewimm/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewimm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewimm/subscriptions","organizations_url":"https://api.github.com/users/andrewimm/orgs","repos_url":"https://api.github.com/users/andrewimm/repos","events_url":"https://api.github.com/users/andrewimm/events{/privacy}","received_events_url":"https://api.github.com/users/andrewimm/received_events","type":"User","site_admin":false},"created_at":"2015-12-08T20:02:39Z","updated_at":"2015-12-08T20:02:39Z","body":"@RaitoBezarius I'm not sure I understand the question. The value of the flag can be retrieved by calling `Parse.Promise.isPromisesAPlusCompliant()`, and the flag can be modified by `Parse.Promise.enableAPlusCompliant()` / `Parse.Promise.enableAPlusCompliant()`. The raw boolean controlling all this is made private."}}