{"action":"created","comment":{"url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/comments/55709591","id":55709591,"diff_hunk":"@@ -0,0 +1,83 @@\n+import MemberEntity from \"../api/memberEntity\";\n+import MemberAPI from \"../api/memberAPI\";\n+import objectAssign = require('object-assign');\n+import MemberFormErrors from \"../validations/memberFormErrors\"\n+import MemberFormValidator from \"../validations/memberFormValidator\"\n+\n+\n+let emptyMemberEntity = new MemberEntity();\n+\n+class MemberState  {\n+  member : MemberEntity;\n+  memberId : number;\n+  errors : MemberFormErrors;\n+  isValid : boolean;\n+  saveCompleted : boolean;\n+\n+  public constructor()\n+  {\n+    this.member = new MemberEntity();\n+    this.memberId = -1;\n+    this.errors = new MemberFormErrors();\n+    this.isValid = false;\n+    this.saveCompleted = false;\n+  }\n+}\n+\n+\n+// Just to show how combine reducers work, we have\n+// divided into two reducers member load + member load/update/delete\n+export default (state : MemberState = new MemberState(), action) => {\n+  let newState : MemberState = null;\n+\n+  switch (action.type) {\n+    case 'MEMBER_NEW':\n+      newState = objectAssign({}, state, {member: new MemberEntity(), errors: new MemberFormErrors(), isValid: false});\n+      return newState;\n+\n+    case 'MEMBER_LOAD':\n+      let member : MemberEntity;\n+      let memberId : number = action[\"id\"];\n+\n+      member = MemberAPI.getMemberById(memberId);\n+      newState = objectAssign({}, state, {dirty: false, member: member, errors: new MemberFormErrors(), isValid: true});\n+\n+      return newState;\n+\n+    case 'MEMBER_UI_INPUT':\n+    //Temporary hack, to force creating a new object (just temporary)\n+    // TODO: enhance this\n+    // We should just treat single UI input (validate on field, check if )\n+    // it has to be included here, ideally not\n+      //let memberUIUpdated : MemberEntity = JSON.parse(JSON.stringify(action[\"member\"]));\n+      let fieldName = action['fieldName'];\n+      let value = action['value']\n+\n+      let newMember : MemberEntity = objectAssign({}, state.member, {});\n+      newMember[fieldName] = value;\n+\n+      newState = objectAssign({}, state, {member: newMember, dirty: true});\n+      return newState;\n+\n+    case 'MEMBER_SAVE':\n+      let errorsSave : MemberFormErrors = MemberFormValidator.validateMember(state.member);\n+\n+      if(errorsSave.isEntityValid == true) {\n+        MemberAPI.saveAuthor(state.member);\n+        // TODO: pending clone member object !! (keep state inmmutable)\n+        newState = objectAssign({}, state, {isValid: true, saveCompleted: true, errors: new MemberFormErrors()});","path":"09 Redux/src/reducers/memberReducer.ts","position":68,"original_position":68,"commit_id":"1169009850bd547899dd19f9a284b533dd596605","original_commit_id":"66b297e7089a6068bcae8806600f392f61f7794f","user":{"login":"Nasdan","id":4374977,"avatar_url":"https://avatars.githubusercontent.com/u/4374977?v=3","gravatar_id":"","url":"https://api.github.com/users/Nasdan","html_url":"https://github.com/Nasdan","followers_url":"https://api.github.com/users/Nasdan/followers","following_url":"https://api.github.com/users/Nasdan/following{/other_user}","gists_url":"https://api.github.com/users/Nasdan/gists{/gist_id}","starred_url":"https://api.github.com/users/Nasdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nasdan/subscriptions","organizations_url":"https://api.github.com/users/Nasdan/orgs","repos_url":"https://api.github.com/users/Nasdan/repos","events_url":"https://api.github.com/users/Nasdan/events{/privacy}","received_events_url":"https://api.github.com/users/Nasdan/received_events","type":"User","site_admin":false},"body":"Where are you using state.isValid property?","created_at":"2016-03-10T16:48:22Z","updated_at":"2016-03-10T16:48:22Z","html_url":"https://github.com/Lemoncode/react-typescript-samples/pull/8#discussion_r55709591","pull_request_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/comments/55709591"},"html":{"href":"https://github.com/Lemoncode/react-typescript-samples/pull/8#discussion_r55709591"},"pull_request":{"href":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/8","id":62353957,"html_url":"https://github.com/Lemoncode/react-typescript-samples/pull/8","diff_url":"https://github.com/Lemoncode/react-typescript-samples/pull/8.diff","patch_url":"https://github.com/Lemoncode/react-typescript-samples/pull/8.patch","issue_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues/8","number":8,"state":"open","locked":false,"title":"Redux support","user":{"login":"brauliodiez","id":1457912,"avatar_url":"https://avatars.githubusercontent.com/u/1457912?v=3","gravatar_id":"","url":"https://api.github.com/users/brauliodiez","html_url":"https://github.com/brauliodiez","followers_url":"https://api.github.com/users/brauliodiez/followers","following_url":"https://api.github.com/users/brauliodiez/following{/other_user}","gists_url":"https://api.github.com/users/brauliodiez/gists{/gist_id}","starred_url":"https://api.github.com/users/brauliodiez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brauliodiez/subscriptions","organizations_url":"https://api.github.com/users/brauliodiez/orgs","repos_url":"https://api.github.com/users/brauliodiez/repos","events_url":"https://api.github.com/users/brauliodiez/events{/privacy}","received_events_url":"https://api.github.com/users/brauliodiez/received_events","type":"User","site_admin":false},"body":"Added sample 09, redux support, using fake api (sync).","created_at":"2016-03-10T08:20:25Z","updated_at":"2016-03-10T16:48:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb9fdc3de0b3fb70c1dacd0b99d085a01eaff287","assignee":{"login":"Nasdan","id":4374977,"avatar_url":"https://avatars.githubusercontent.com/u/4374977?v=3","gravatar_id":"","url":"https://api.github.com/users/Nasdan","html_url":"https://github.com/Nasdan","followers_url":"https://api.github.com/users/Nasdan/followers","following_url":"https://api.github.com/users/Nasdan/following{/other_user}","gists_url":"https://api.github.com/users/Nasdan/gists{/gist_id}","starred_url":"https://api.github.com/users/Nasdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nasdan/subscriptions","organizations_url":"https://api.github.com/users/Nasdan/orgs","repos_url":"https://api.github.com/users/Nasdan/repos","events_url":"https://api.github.com/users/Nasdan/events{/privacy}","received_events_url":"https://api.github.com/users/Nasdan/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/8/commits","review_comments_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/8/comments","review_comment_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues/8/comments","statuses_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/statuses/1169009850bd547899dd19f9a284b533dd596605","head":{"label":"Lemoncode:Redux_Support","ref":"Redux_Support","sha":"1169009850bd547899dd19f9a284b533dd596605","user":{"login":"Lemoncode","id":7702396,"avatar_url":"https://avatars.githubusercontent.com/u/7702396?v=3","gravatar_id":"","url":"https://api.github.com/users/Lemoncode","html_url":"https://github.com/Lemoncode","followers_url":"https://api.github.com/users/Lemoncode/followers","following_url":"https://api.github.com/users/Lemoncode/following{/other_user}","gists_url":"https://api.github.com/users/Lemoncode/gists{/gist_id}","starred_url":"https://api.github.com/users/Lemoncode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lemoncode/subscriptions","organizations_url":"https://api.github.com/users/Lemoncode/orgs","repos_url":"https://api.github.com/users/Lemoncode/repos","events_url":"https://api.github.com/users/Lemoncode/events{/privacy}","received_events_url":"https://api.github.com/users/Lemoncode/received_events","type":"Organization","site_admin":false},"repo":{"id":52718939,"name":"react-typescript-samples","full_name":"Lemoncode/react-typescript-samples","owner":{"login":"Lemoncode","id":7702396,"avatar_url":"https://avatars.githubusercontent.com/u/7702396?v=3","gravatar_id":"","url":"https://api.github.com/users/Lemoncode","html_url":"https://github.com/Lemoncode","followers_url":"https://api.github.com/users/Lemoncode/followers","following_url":"https://api.github.com/users/Lemoncode/following{/other_user}","gists_url":"https://api.github.com/users/Lemoncode/gists{/gist_id}","starred_url":"https://api.github.com/users/Lemoncode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lemoncode/subscriptions","organizations_url":"https://api.github.com/users/Lemoncode/orgs","repos_url":"https://api.github.com/users/Lemoncode/repos","events_url":"https://api.github.com/users/Lemoncode/events{/privacy}","received_events_url":"https://api.github.com/users/Lemoncode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Lemoncode/react-typescript-samples","description":"The goal of this project is to provide a set of simple samples, providing and step by step guide to start working with React and Typescript.","fork":false,"url":"https://api.github.com/repos/Lemoncode/react-typescript-samples","forks_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/forks","keys_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/teams","hooks_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/hooks","issue_events_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues/events{/number}","events_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/events","assignees_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/assignees{/user}","branches_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/branches{/branch}","tags_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/tags","blobs_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/statuses/{sha}","languages_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/languages","stargazers_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/stargazers","contributors_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/contributors","subscribers_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/subscribers","subscription_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/subscription","commits_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/contents/{+path}","compare_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/merges","archive_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/downloads","issues_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues{/number}","pulls_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls{/number}","milestones_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/milestones{/number}","notifications_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/labels{/name}","releases_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/releases{/id}","deployments_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/deployments","created_at":"2016-02-28T11:58:58Z","updated_at":"2016-03-10T05:59:55Z","pushed_at":"2016-03-10T16:43:25Z","git_url":"git://github.com/Lemoncode/react-typescript-samples.git","ssh_url":"git@github.com:Lemoncode/react-typescript-samples.git","clone_url":"https://github.com/Lemoncode/react-typescript-samples.git","svn_url":"https://github.com/Lemoncode/react-typescript-samples","homepage":null,"size":48,"stargazers_count":9,"watchers_count":9,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":7,"forks":3,"open_issues":7,"watchers":9,"default_branch":"master"}},"base":{"label":"Lemoncode:master","ref":"master","sha":"3c973e71cacbc296a57841251a0d14211f603f37","user":{"login":"Lemoncode","id":7702396,"avatar_url":"https://avatars.githubusercontent.com/u/7702396?v=3","gravatar_id":"","url":"https://api.github.com/users/Lemoncode","html_url":"https://github.com/Lemoncode","followers_url":"https://api.github.com/users/Lemoncode/followers","following_url":"https://api.github.com/users/Lemoncode/following{/other_user}","gists_url":"https://api.github.com/users/Lemoncode/gists{/gist_id}","starred_url":"https://api.github.com/users/Lemoncode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lemoncode/subscriptions","organizations_url":"https://api.github.com/users/Lemoncode/orgs","repos_url":"https://api.github.com/users/Lemoncode/repos","events_url":"https://api.github.com/users/Lemoncode/events{/privacy}","received_events_url":"https://api.github.com/users/Lemoncode/received_events","type":"Organization","site_admin":false},"repo":{"id":52718939,"name":"react-typescript-samples","full_name":"Lemoncode/react-typescript-samples","owner":{"login":"Lemoncode","id":7702396,"avatar_url":"https://avatars.githubusercontent.com/u/7702396?v=3","gravatar_id":"","url":"https://api.github.com/users/Lemoncode","html_url":"https://github.com/Lemoncode","followers_url":"https://api.github.com/users/Lemoncode/followers","following_url":"https://api.github.com/users/Lemoncode/following{/other_user}","gists_url":"https://api.github.com/users/Lemoncode/gists{/gist_id}","starred_url":"https://api.github.com/users/Lemoncode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lemoncode/subscriptions","organizations_url":"https://api.github.com/users/Lemoncode/orgs","repos_url":"https://api.github.com/users/Lemoncode/repos","events_url":"https://api.github.com/users/Lemoncode/events{/privacy}","received_events_url":"https://api.github.com/users/Lemoncode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Lemoncode/react-typescript-samples","description":"The goal of this project is to provide a set of simple samples, providing and step by step guide to start working with React and Typescript.","fork":false,"url":"https://api.github.com/repos/Lemoncode/react-typescript-samples","forks_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/forks","keys_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/teams","hooks_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/hooks","issue_events_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues/events{/number}","events_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/events","assignees_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/assignees{/user}","branches_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/branches{/branch}","tags_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/tags","blobs_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/statuses/{sha}","languages_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/languages","stargazers_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/stargazers","contributors_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/contributors","subscribers_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/subscribers","subscription_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/subscription","commits_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/contents/{+path}","compare_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/merges","archive_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/downloads","issues_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues{/number}","pulls_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls{/number}","milestones_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/milestones{/number}","notifications_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/labels{/name}","releases_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/releases{/id}","deployments_url":"https://api.github.com/repos/Lemoncode/react-typescript-samples/deployments","created_at":"2016-02-28T11:58:58Z","updated_at":"2016-03-10T05:59:55Z","pushed_at":"2016-03-10T16:43:25Z","git_url":"git://github.com/Lemoncode/react-typescript-samples.git","ssh_url":"git@github.com:Lemoncode/react-typescript-samples.git","clone_url":"https://github.com/Lemoncode/react-typescript-samples.git","svn_url":"https://github.com/Lemoncode/react-typescript-samples","homepage":null,"size":48,"stargazers_count":9,"watchers_count":9,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":7,"forks":3,"open_issues":7,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/8"},"html":{"href":"https://github.com/Lemoncode/react-typescript-samples/pull/8"},"issue":{"href":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues/8"},"comments":{"href":"https://api.github.com/repos/Lemoncode/react-typescript-samples/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Lemoncode/react-typescript-samples/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/Lemoncode/react-typescript-samples/statuses/1169009850bd547899dd19f9a284b533dd596605"}}}}