{"action":"created","comment":{"url":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/comments/58216339","id":58216339,"diff_hunk":"@@ -48,6 +48,11 @@ function inject(state, action, props, scenes) {\n             case POP_ACTION:\n                 assert(!state.tabs, \"pop() operation cannot be run on tab bar (tabs=true)\")\n                 return {...state, index:state.index-1, children:state.children.slice(0, -1) };\n+            case POP_TO_TOP:\n+                assert(state.tabs, \"Parent=\"+state.key+\" is not tab bar, popToTop action is not valid\");\n+                let child = state.children[state.index];\n+                let newChild = {...child, ...{children: [child.children[0]], index:0}};\n+                return {...state, ...{children:[...state.children.slice(0,state.index), newChild, ...state.children.slice(state.index+1)]}};","path":"src/Reducer.js","position":17,"original_position":17,"commit_id":"3b39452d479c815a606317969436020970f1b29d","original_commit_id":"3b39452d479c815a606317969436020970f1b29d","user":{"login":"aksonov","id":1321329,"avatar_url":"https://avatars.githubusercontent.com/u/1321329?v=3","gravatar_id":"","url":"https://api.github.com/users/aksonov","html_url":"https://github.com/aksonov","followers_url":"https://api.github.com/users/aksonov/followers","following_url":"https://api.github.com/users/aksonov/following{/other_user}","gists_url":"https://api.github.com/users/aksonov/gists{/gist_id}","starred_url":"https://api.github.com/users/aksonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aksonov/subscriptions","organizations_url":"https://api.github.com/users/aksonov/orgs","repos_url":"https://api.github.com/users/aksonov/repos","events_url":"https://api.github.com/users/aksonov/events{/privacy}","received_events_url":"https://api.github.com/users/aksonov/received_events","type":"User","site_admin":false},"body":"So could you make it in the same way as POP action ? Then it will work for both tabs/stacks and it will be much simpler (just return first single child as children array)","created_at":"2016-04-01T14:49:26Z","updated_at":"2016-04-01T14:49:26Z","html_url":"https://github.com/aksonov/react-native-router-flux/pull/450#discussion_r58216339","pull_request_url":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/450","_links":{"self":{"href":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/comments/58216339"},"html":{"href":"https://github.com/aksonov/react-native-router-flux/pull/450#discussion_r58216339"},"pull_request":{"href":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/450"}}},"pull_request":{"url":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/450","id":64952171,"html_url":"https://github.com/aksonov/react-native-router-flux/pull/450","diff_url":"https://github.com/aksonov/react-native-router-flux/pull/450.diff","patch_url":"https://github.com/aksonov/react-native-router-flux/pull/450.patch","issue_url":"https://api.github.com/repos/aksonov/react-native-router-flux/issues/450","number":450,"state":"open","locked":false,"title":"Added popToTop functionality","user":{"login":"AlexDM0","id":5363277,"avatar_url":"https://avatars.githubusercontent.com/u/5363277?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexDM0","html_url":"https://github.com/AlexDM0","followers_url":"https://api.github.com/users/AlexDM0/followers","following_url":"https://api.github.com/users/AlexDM0/following{/other_user}","gists_url":"https://api.github.com/users/AlexDM0/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexDM0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexDM0/subscriptions","organizations_url":"https://api.github.com/users/AlexDM0/orgs","repos_url":"https://api.github.com/users/AlexDM0/repos","events_url":"https://api.github.com/users/AlexDM0/events{/privacy}","received_events_url":"https://api.github.com/users/AlexDM0/received_events","type":"User","site_admin":false},"body":"Hi,\r\n\r\nIn my app there are a few tabs, and the state is persisted if you toggle between them (thanks to PR #390). If you are already inside the tab however, I would like the state to be reset to the base of the tab for easy navigation. \r\n\r\nI've added an action called popToTop (name based on https://facebook.github.io/react-native/docs/navigator.html#content). \r\n\r\nI can now do this in my reducer:\r\n```js\r\nconst reducerCreate = params=> {\r\n  const defaultReducer = Reducer(params);\r\n  return (state, action)=>{\r\n    if (state) {\r\n      let currentTabIndex = state.children[0].index;\r\n      if (state.children[0].children[currentTabIndex].name === action.key && action.type === 'jump') {\r\n        return defaultReducer(state, {...action, ...{type:'popToTop'}});\r\n      }\r\n    }\r\n    return defaultReducer(state, action);\r\n  }\r\n};\r\n```\r\n\r\nI figured I'd do a pull to see if you'd like to add it to the repo. I couldnt find where in the docs it would be added but if you can point me to it I can add it there too.\r\n\r\nRegards","created_at":"2016-04-01T14:23:58Z","updated_at":"2016-04-01T14:49:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9601e4bfd156d821b28874a420e600356aade09f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/450/commits","review_comments_url":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/450/comments","review_comment_url":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aksonov/react-native-router-flux/issues/450/comments","statuses_url":"https://api.github.com/repos/aksonov/react-native-router-flux/statuses/3b39452d479c815a606317969436020970f1b29d","head":{"label":"AlexDM0:master","ref":"master","sha":"3b39452d479c815a606317969436020970f1b29d","user":{"login":"AlexDM0","id":5363277,"avatar_url":"https://avatars.githubusercontent.com/u/5363277?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexDM0","html_url":"https://github.com/AlexDM0","followers_url":"https://api.github.com/users/AlexDM0/followers","following_url":"https://api.github.com/users/AlexDM0/following{/other_user}","gists_url":"https://api.github.com/users/AlexDM0/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexDM0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexDM0/subscriptions","organizations_url":"https://api.github.com/users/AlexDM0/orgs","repos_url":"https://api.github.com/users/AlexDM0/repos","events_url":"https://api.github.com/users/AlexDM0/events{/privacy}","received_events_url":"https://api.github.com/users/AlexDM0/received_events","type":"User","site_admin":false},"repo":{"id":55237443,"name":"react-native-router-flux","full_name":"AlexDM0/react-native-router-flux","owner":{"login":"AlexDM0","id":5363277,"avatar_url":"https://avatars.githubusercontent.com/u/5363277?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexDM0","html_url":"https://github.com/AlexDM0","followers_url":"https://api.github.com/users/AlexDM0/followers","following_url":"https://api.github.com/users/AlexDM0/following{/other_user}","gists_url":"https://api.github.com/users/AlexDM0/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexDM0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexDM0/subscriptions","organizations_url":"https://api.github.com/users/AlexDM0/orgs","repos_url":"https://api.github.com/users/AlexDM0/repos","events_url":"https://api.github.com/users/AlexDM0/events{/privacy}","received_events_url":"https://api.github.com/users/AlexDM0/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AlexDM0/react-native-router-flux","description":"React Native Router based on new React Native Navigation API","fork":true,"url":"https://api.github.com/repos/AlexDM0/react-native-router-flux","forks_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/forks","keys_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/teams","hooks_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/hooks","issue_events_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/issues/events{/number}","events_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/events","assignees_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/assignees{/user}","branches_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/branches{/branch}","tags_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/tags","blobs_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/git/refs{/sha}","trees_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/statuses/{sha}","languages_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/languages","stargazers_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/stargazers","contributors_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/contributors","subscribers_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/subscribers","subscription_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/subscription","commits_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/commits{/sha}","git_commits_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/git/commits{/sha}","comments_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/comments{/number}","issue_comment_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/issues/comments{/number}","contents_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/contents/{+path}","compare_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/merges","archive_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/downloads","issues_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/issues{/number}","pulls_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/pulls{/number}","milestones_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/milestones{/number}","notifications_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/labels{/name}","releases_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/releases{/id}","deployments_url":"https://api.github.com/repos/AlexDM0/react-native-router-flux/deployments","created_at":"2016-04-01T14:15:00Z","updated_at":"2016-04-01T14:15:01Z","pushed_at":"2016-04-01T14:19:34Z","git_url":"git://github.com/AlexDM0/react-native-router-flux.git","ssh_url":"git@github.com:AlexDM0/react-native-router-flux.git","clone_url":"https://github.com/AlexDM0/react-native-router-flux.git","svn_url":"https://github.com/AlexDM0/react-native-router-flux","homepage":"","size":832,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"aksonov:master","ref":"master","sha":"dcc75584912a8567e9be83b43cd48bcb6942231b","user":{"login":"aksonov","id":1321329,"avatar_url":"https://avatars.githubusercontent.com/u/1321329?v=3","gravatar_id":"","url":"https://api.github.com/users/aksonov","html_url":"https://github.com/aksonov","followers_url":"https://api.github.com/users/aksonov/followers","following_url":"https://api.github.com/users/aksonov/following{/other_user}","gists_url":"https://api.github.com/users/aksonov/gists{/gist_id}","starred_url":"https://api.github.com/users/aksonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aksonov/subscriptions","organizations_url":"https://api.github.com/users/aksonov/orgs","repos_url":"https://api.github.com/users/aksonov/repos","events_url":"https://api.github.com/users/aksonov/events{/privacy}","received_events_url":"https://api.github.com/users/aksonov/received_events","type":"User","site_admin":false},"repo":{"id":41359055,"name":"react-native-router-flux","full_name":"aksonov/react-native-router-flux","owner":{"login":"aksonov","id":1321329,"avatar_url":"https://avatars.githubusercontent.com/u/1321329?v=3","gravatar_id":"","url":"https://api.github.com/users/aksonov","html_url":"https://github.com/aksonov","followers_url":"https://api.github.com/users/aksonov/followers","following_url":"https://api.github.com/users/aksonov/following{/other_user}","gists_url":"https://api.github.com/users/aksonov/gists{/gist_id}","starred_url":"https://api.github.com/users/aksonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aksonov/subscriptions","organizations_url":"https://api.github.com/users/aksonov/orgs","repos_url":"https://api.github.com/users/aksonov/repos","events_url":"https://api.github.com/users/aksonov/events{/privacy}","received_events_url":"https://api.github.com/users/aksonov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aksonov/react-native-router-flux","description":"React Native Router based on new React Native Navigation API","fork":false,"url":"https://api.github.com/repos/aksonov/react-native-router-flux","forks_url":"https://api.github.com/repos/aksonov/react-native-router-flux/forks","keys_url":"https://api.github.com/repos/aksonov/react-native-router-flux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aksonov/react-native-router-flux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aksonov/react-native-router-flux/teams","hooks_url":"https://api.github.com/repos/aksonov/react-native-router-flux/hooks","issue_events_url":"https://api.github.com/repos/aksonov/react-native-router-flux/issues/events{/number}","events_url":"https://api.github.com/repos/aksonov/react-native-router-flux/events","assignees_url":"https://api.github.com/repos/aksonov/react-native-router-flux/assignees{/user}","branches_url":"https://api.github.com/repos/aksonov/react-native-router-flux/branches{/branch}","tags_url":"https://api.github.com/repos/aksonov/react-native-router-flux/tags","blobs_url":"https://api.github.com/repos/aksonov/react-native-router-flux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aksonov/react-native-router-flux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aksonov/react-native-router-flux/git/refs{/sha}","trees_url":"https://api.github.com/repos/aksonov/react-native-router-flux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aksonov/react-native-router-flux/statuses/{sha}","languages_url":"https://api.github.com/repos/aksonov/react-native-router-flux/languages","stargazers_url":"https://api.github.com/repos/aksonov/react-native-router-flux/stargazers","contributors_url":"https://api.github.com/repos/aksonov/react-native-router-flux/contributors","subscribers_url":"https://api.github.com/repos/aksonov/react-native-router-flux/subscribers","subscription_url":"https://api.github.com/repos/aksonov/react-native-router-flux/subscription","commits_url":"https://api.github.com/repos/aksonov/react-native-router-flux/commits{/sha}","git_commits_url":"https://api.github.com/repos/aksonov/react-native-router-flux/git/commits{/sha}","comments_url":"https://api.github.com/repos/aksonov/react-native-router-flux/comments{/number}","issue_comment_url":"https://api.github.com/repos/aksonov/react-native-router-flux/issues/comments{/number}","contents_url":"https://api.github.com/repos/aksonov/react-native-router-flux/contents/{+path}","compare_url":"https://api.github.com/repos/aksonov/react-native-router-flux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aksonov/react-native-router-flux/merges","archive_url":"https://api.github.com/repos/aksonov/react-native-router-flux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aksonov/react-native-router-flux/downloads","issues_url":"https://api.github.com/repos/aksonov/react-native-router-flux/issues{/number}","pulls_url":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls{/number}","milestones_url":"https://api.github.com/repos/aksonov/react-native-router-flux/milestones{/number}","notifications_url":"https://api.github.com/repos/aksonov/react-native-router-flux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aksonov/react-native-router-flux/labels{/name}","releases_url":"https://api.github.com/repos/aksonov/react-native-router-flux/releases{/id}","deployments_url":"https://api.github.com/repos/aksonov/react-native-router-flux/deployments","created_at":"2015-08-25T11:12:44Z","updated_at":"2016-04-01T14:42:19Z","pushed_at":"2016-04-01T14:23:58Z","git_url":"git://github.com/aksonov/react-native-router-flux.git","ssh_url":"git@github.com:aksonov/react-native-router-flux.git","clone_url":"https://github.com/aksonov/react-native-router-flux.git","svn_url":"https://github.com/aksonov/react-native-router-flux","homepage":"","size":869,"stargazers_count":824,"watchers_count":824,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":166,"mirror_url":null,"open_issues_count":17,"forks":166,"open_issues":17,"watchers":824,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/450"},"html":{"href":"https://github.com/aksonov/react-native-router-flux/pull/450"},"issue":{"href":"https://api.github.com/repos/aksonov/react-native-router-flux/issues/450"},"comments":{"href":"https://api.github.com/repos/aksonov/react-native-router-flux/issues/450/comments"},"review_comments":{"href":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/450/comments"},"review_comment":{"href":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aksonov/react-native-router-flux/pulls/450/commits"},"statuses":{"href":"https://api.github.com/repos/aksonov/react-native-router-flux/statuses/3b39452d479c815a606317969436020970f1b29d"}}}}