{"action":"opened","issue":{"url":"https://api.github.com/repos/dracupid/light-promise/issues/2","repository_url":"https://api.github.com/repos/dracupid/light-promise","labels_url":"https://api.github.com/repos/dracupid/light-promise/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/dracupid/light-promise/issues/2/comments","events_url":"https://api.github.com/repos/dracupid/light-promise/issues/2/events","html_url":"https://github.com/dracupid/light-promise/issues/2","id":152758898,"number":2,"title":"Resolving a promise1 with a promise2 should return the promise2 resolved value","user":{"login":"astik","id":572233,"avatar_url":"https://avatars.githubusercontent.com/u/572233?v=3","gravatar_id":"","url":"https://api.github.com/users/astik","html_url":"https://github.com/astik","followers_url":"https://api.github.com/users/astik/followers","following_url":"https://api.github.com/users/astik/following{/other_user}","gists_url":"https://api.github.com/users/astik/gists{/gist_id}","starred_url":"https://api.github.com/users/astik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astik/subscriptions","organizations_url":"https://api.github.com/users/astik/orgs","repos_url":"https://api.github.com/users/astik/repos","events_url":"https://api.github.com/users/astik/events{/privacy}","received_events_url":"https://api.github.com/users/astik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-03T12:12:16Z","updated_at":"2016-05-03T12:12:16Z","closed_at":null,"body":"Here is the code for the resolve function :\r\n\r\n```js\r\n    Promise.prototype.resolve = function(value1) {\r\n      this.value = value1;\r\n      if (this.state === 'fulfilled') {\r\n        return this;\r\n      }\r\n      this.state = 'fulfilled';\r\n      this._fireResolve();\r\n      return this;\r\n    };\r\n```\r\n\r\nOn https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve, documentation says :\r\n```\r\nThe Promise.resolve(value) method returns a Promise object that is resolved with the given value. If the value is a thenable (i.e. has a then method), the returned promise will \"follow\" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the value.\r\n```\r\n\r\nSo that, value1 should be resolved before getting affected to this.value.\r\n\r\nAs a workaround, till fixing the library, we can code this by resolving promise2 and then resolving promise1 :\r\n\r\ninstead of coding this :\r\n```js\r\n   var promise1 = new Promise();\r\n   var promise2 = new Promise();\r\n   promise1.resolve(promise2);\r\n```\r\n\r\nwe can code that :\r\n```js\r\n   var promise1 = new Promise();\r\n   var promise2 = new Promise();\r\n   promise2.then(function(value){\r\n      promise1.resolve(value);\r\n   }\r\n```\r\n"}}