{"action":"created","issue":{"url":"https://api.github.com/repos/CodeNow/code-styleguide/issues/4","repository_url":"https://api.github.com/repos/CodeNow/code-styleguide","labels_url":"https://api.github.com/repos/CodeNow/code-styleguide/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/CodeNow/code-styleguide/issues/4/comments","events_url":"https://api.github.com/repos/CodeNow/code-styleguide/issues/4/events","html_url":"https://github.com/CodeNow/code-styleguide/issues/4","id":167744525,"number":4,"title":"Promise patterns","user":{"login":"anandkumarpatel","id":2194285,"avatar_url":"https://avatars.githubusercontent.com/u/2194285?v=3","gravatar_id":"","url":"https://api.github.com/users/anandkumarpatel","html_url":"https://github.com/anandkumarpatel","followers_url":"https://api.github.com/users/anandkumarpatel/followers","following_url":"https://api.github.com/users/anandkumarpatel/following{/other_user}","gists_url":"https://api.github.com/users/anandkumarpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/anandkumarpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anandkumarpatel/subscriptions","organizations_url":"https://api.github.com/users/anandkumarpatel/orgs","repos_url":"https://api.github.com/users/anandkumarpatel/repos","events_url":"https://api.github.com/users/anandkumarpatel/events{/privacy}","received_events_url":"https://api.github.com/users/anandkumarpatel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-27T00:46:25Z","updated_at":"2016-07-27T01:30:23Z","closed_at":null,"body":"Let us discuss our new coding patterns now that we moved everything to promises:\r\n\r\n\r\nMethod 1 Linear program w/ comments\r\n```\r\nPromise.try(() {\r\n  // JSDoc\r\n  ... code ...\r\n})\r\n.then(doSomething1 () {\r\n  // JSDoc\r\n  ... code ...\r\n})\r\n.then(doSomething2 () {\r\n  // JSDoc\r\n  ... code ...\r\n})\r\n.then(doSomething3 () {\r\n  // JSDoc\r\n  ... code ...\r\n})\r\n```\r\nPro: looks linear\r\nCons: unit testing is harder, requires more setup\r\n\r\nMethod 2 Functional\r\n```\r\nPromise.try(() {\r\n return fn1()\r\n})\r\n.then(() {\r\n  return fn2()\r\n})\r\n.then(() {\r\n return fn3()\r\n})\r\n.then(() {\r\n return fn4()\r\n})\r\n// JSDoc\r\nfn1 = {\r\n  ... code ...\r\n}\r\n// JSDoc\r\nfn2 = {\r\n  ... code ...\r\n}\r\n// JSDoc\r\nfn3 = {\r\n  ... code ...\r\n}\r\n// JSDoc\r\nfn4 = {\r\n  ... code ...\r\n}\r\n```\r\n\r\nPro: functions are broken up into smaller components\r\nCon: have to look at different areas on the page to understand full function.\r\n\r\nAny other methods people prefer & which do you like the most?"},"comment":{"url":"https://api.github.com/repos/CodeNow/code-styleguide/issues/comments/235455738","html_url":"https://github.com/CodeNow/code-styleguide/issues/4#issuecomment-235455738","issue_url":"https://api.github.com/repos/CodeNow/code-styleguide/issues/4","id":235455738,"user":{"login":"podviaznikov","id":429706,"avatar_url":"https://avatars.githubusercontent.com/u/429706?v=3","gravatar_id":"","url":"https://api.github.com/users/podviaznikov","html_url":"https://github.com/podviaznikov","followers_url":"https://api.github.com/users/podviaznikov/followers","following_url":"https://api.github.com/users/podviaznikov/following{/other_user}","gists_url":"https://api.github.com/users/podviaznikov/gists{/gist_id}","starred_url":"https://api.github.com/users/podviaznikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/podviaznikov/subscriptions","organizations_url":"https://api.github.com/users/podviaznikov/orgs","repos_url":"https://api.github.com/users/podviaznikov/repos","events_url":"https://api.github.com/users/podviaznikov/events{/privacy}","received_events_url":"https://api.github.com/users/podviaznikov/received_events","type":"User","site_admin":false},"created_at":"2016-07-27T01:30:23Z","updated_at":"2016-07-27T01:30:23Z","body":"haha, code folding is workaround in order to achieve same feature as Method 2 provides. I'd rather have Method 2, but code folding with Method 3 would work for me too."}}
{"actor":{"display_login":"podviaznikov"}}