{"action":"created","comment":{"url":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/comments/118643591","pull_request_review_id":40455447,"id":118643591,"diff_hunk":"@@ -64,12 +102,102 @@ extension TweetDetailViewController {\n     \n     fileprivate func setupView() {\n         view.addSubview(contentLabel)\n+        view.addSubview(inputCommentTextField)\n+        view.addSubview(submitCommentButton)\n+        view.addSubview(deleteTweetButton)\n+        view.addSubview(commentsTableView)\n     }\n     \n     fileprivate func setupLayout() {\n         contentLabel.snp.makeConstraints { make in\n             make.center.equalTo(view)\n             make.left.right.equalTo(view).inset(16)\n         }\n+        \n+        inputCommentTextField.snp.makeConstraints { make in\n+            make.centerX.equalTo(view)\n+            make.top.equalTo(contentLabel.snp.bottom).offset(16)\n+            make.width.equalTo(200)\n+            make.height.equalTo(32)\n+        }\n+        \n+        submitCommentButton.snp.makeConstraints { make in\n+            make.left.equalTo(inputCommentTextField.snp.right).offset(12)\n+            make.centerY.equalTo(inputCommentTextField)\n+            make.width.height.equalTo(32)\n+        }\n+        \n+        deleteTweetButton.snp.makeConstraints { make in\n+            make.left.equalTo(submitCommentButton.snp.right).offset(12)\n+            make.centerY.equalTo(submitCommentButton)\n+            make.width.height.equalTo(32)\n+        }\n+        \n+        commentsTableView.snp.makeConstraints { make in\n+            make.left.right.bottom.equalTo(view)\n+            make.top.equalTo(inputCommentTextField.snp.bottom).offset(32)\n+        }\n+    }\n+    \n+    fileprivate func subscribeView() {\n+        submitCommentButton.rx.tap\n+            .filter { [weak self] in\n+                self?.inputCommentTextField.text?.isEmpty == false\n+            }\n+            .subscribe(onNext: { [weak self] in\n+                guard let unwrappedSelf = self else { return }\n+                \n+                unwrappedSelf.viewModel.inputs.submit\n+                    .onNext(unwrappedSelf.inputCommentTextField.text!)\n+                unwrappedSelf.inputCommentTextField.text = \"\"\n+            })\n+            .disposed(by: disposeBag)\n+        \n+        deleteTweetButton.rx.tap\n+            .subscribe(onNext: { [weak self] in\n+                self?.viewModel.inputs.deletion.onNext()\n+            })\n+            .disposed(by: disposeBag)\n+    }\n+    \n+    fileprivate func subscribeViewModel() {\n+        viewModel.outputs.commentsVariable.asObservable()\n+            .subscribe(onNext: { [weak self] _ in\n+                self?.commentsTableView.reloadData()\n+            })\n+            .disposed(by: disposeBag)\n+        \n+        viewModel.outputs.deleteSuccess\n+            .subscribe(onNext: { [weak self] isSuccess in\n+                if isSuccess {\n+                    _ = self?.navigationController?.popViewController(animated: true)\n+                }\n+                else {\n+                    let alertView = UIAlertController(title: \"削除失敗\", message: \"ツイートの削除に失敗しました\",\n+                                                      preferredStyle: .alert)\n+                    alertView.addAction(UIAlertAction(title: \"OK\", style: .cancel))\n+                    self?.present(alertView, animated: true)\n+                }\n+            })\n+            .disposed(by: disposeBag)\n+    }\n+}\n+\n+\n+// MARK: - UITableViewDataSource -\n+\n+extension TweetDetailViewController: UITableViewDataSource {\n+    \n+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n+        guard let comments = viewModel.outputs.commentsVariable.value else { return 0 }\n+        return comments.count","path":"TweetDetailViewController.swift","position":163,"original_position":163,"commit_id":"6d9705dcbd97031c5981ea4f15bbc712c3e22318","original_commit_id":"6d9705dcbd97031c5981ea4f15bbc712c3e22318","user":{"login":"yukitoto","id":7534018,"avatar_url":"https://avatars0.githubusercontent.com/u/7534018?v=3","gravatar_id":"","url":"https://api.github.com/users/yukitoto","html_url":"https://github.com/yukitoto","followers_url":"https://api.github.com/users/yukitoto/followers","following_url":"https://api.github.com/users/yukitoto/following{/other_user}","gists_url":"https://api.github.com/users/yukitoto/gists{/gist_id}","starred_url":"https://api.github.com/users/yukitoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yukitoto/subscriptions","organizations_url":"https://api.github.com/users/yukitoto/orgs","repos_url":"https://api.github.com/users/yukitoto/repos","events_url":"https://api.github.com/users/yukitoto/events{/privacy}","received_events_url":"https://api.github.com/users/yukitoto/received_events","type":"User","site_admin":false},"body":"viewModel.outputs.commentsVariable.value?.count ?? 0\r\n\r\nって書ける。複雑な式でこれをやるとコンパイルの遅くなるので使いかたには注意は必要だけど","created_at":"2017-05-26T06:50:48Z","updated_at":"2017-05-26T06:54:41Z","html_url":"https://github.com/hiramekun/TwitterSample/pull/10#discussion_r118643591","pull_request_url":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/comments/118643591"},"html":{"href":"https://github.com/hiramekun/TwitterSample/pull/10#discussion_r118643591"},"pull_request":{"href":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/10","id":122581378,"html_url":"https://github.com/hiramekun/TwitterSample/pull/10","diff_url":"https://github.com/hiramekun/TwitterSample/pull/10.diff","patch_url":"https://github.com/hiramekun/TwitterSample/pull/10.patch","issue_url":"https://api.github.com/repos/hiramekun/TwitterSample/issues/10","number":10,"state":"open","locked":false,"title":"ツイートの削除を実装しました","user":{"login":"hiramekun","id":20180425,"avatar_url":"https://avatars2.githubusercontent.com/u/20180425?v=3","gravatar_id":"","url":"https://api.github.com/users/hiramekun","html_url":"https://github.com/hiramekun","followers_url":"https://api.github.com/users/hiramekun/followers","following_url":"https://api.github.com/users/hiramekun/following{/other_user}","gists_url":"https://api.github.com/users/hiramekun/gists{/gist_id}","starred_url":"https://api.github.com/users/hiramekun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiramekun/subscriptions","organizations_url":"https://api.github.com/users/hiramekun/orgs","repos_url":"https://api.github.com/users/hiramekun/repos","events_url":"https://api.github.com/users/hiramekun/events{/privacy}","received_events_url":"https://api.github.com/users/hiramekun/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-05-26T06:41:18Z","updated_at":"2017-05-26T06:54:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"657a3b2afdf3cd2ae5d0763ae6b34c3e5af36af2","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/10/commits","review_comments_url":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/10/comments","review_comment_url":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hiramekun/TwitterSample/issues/10/comments","statuses_url":"https://api.github.com/repos/hiramekun/TwitterSample/statuses/6d9705dcbd97031c5981ea4f15bbc712c3e22318","head":{"label":"hiramekun:feature-deleteTweet","ref":"feature-deleteTweet","sha":"6d9705dcbd97031c5981ea4f15bbc712c3e22318","user":{"login":"hiramekun","id":20180425,"avatar_url":"https://avatars2.githubusercontent.com/u/20180425?v=3","gravatar_id":"","url":"https://api.github.com/users/hiramekun","html_url":"https://github.com/hiramekun","followers_url":"https://api.github.com/users/hiramekun/followers","following_url":"https://api.github.com/users/hiramekun/following{/other_user}","gists_url":"https://api.github.com/users/hiramekun/gists{/gist_id}","starred_url":"https://api.github.com/users/hiramekun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiramekun/subscriptions","organizations_url":"https://api.github.com/users/hiramekun/orgs","repos_url":"https://api.github.com/users/hiramekun/repos","events_url":"https://api.github.com/users/hiramekun/events{/privacy}","received_events_url":"https://api.github.com/users/hiramekun/received_events","type":"User","site_admin":false},"repo":{"id":91140987,"name":"TwitterSample","full_name":"hiramekun/TwitterSample","owner":{"login":"hiramekun","id":20180425,"avatar_url":"https://avatars2.githubusercontent.com/u/20180425?v=3","gravatar_id":"","url":"https://api.github.com/users/hiramekun","html_url":"https://github.com/hiramekun","followers_url":"https://api.github.com/users/hiramekun/followers","following_url":"https://api.github.com/users/hiramekun/following{/other_user}","gists_url":"https://api.github.com/users/hiramekun/gists{/gist_id}","starred_url":"https://api.github.com/users/hiramekun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiramekun/subscriptions","organizations_url":"https://api.github.com/users/hiramekun/orgs","repos_url":"https://api.github.com/users/hiramekun/repos","events_url":"https://api.github.com/users/hiramekun/events{/privacy}","received_events_url":"https://api.github.com/users/hiramekun/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hiramekun/TwitterSample","description":"RxとRealmの練習","fork":false,"url":"https://api.github.com/repos/hiramekun/TwitterSample","forks_url":"https://api.github.com/repos/hiramekun/TwitterSample/forks","keys_url":"https://api.github.com/repos/hiramekun/TwitterSample/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hiramekun/TwitterSample/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hiramekun/TwitterSample/teams","hooks_url":"https://api.github.com/repos/hiramekun/TwitterSample/hooks","issue_events_url":"https://api.github.com/repos/hiramekun/TwitterSample/issues/events{/number}","events_url":"https://api.github.com/repos/hiramekun/TwitterSample/events","assignees_url":"https://api.github.com/repos/hiramekun/TwitterSample/assignees{/user}","branches_url":"https://api.github.com/repos/hiramekun/TwitterSample/branches{/branch}","tags_url":"https://api.github.com/repos/hiramekun/TwitterSample/tags","blobs_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/refs{/sha}","trees_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hiramekun/TwitterSample/statuses/{sha}","languages_url":"https://api.github.com/repos/hiramekun/TwitterSample/languages","stargazers_url":"https://api.github.com/repos/hiramekun/TwitterSample/stargazers","contributors_url":"https://api.github.com/repos/hiramekun/TwitterSample/contributors","subscribers_url":"https://api.github.com/repos/hiramekun/TwitterSample/subscribers","subscription_url":"https://api.github.com/repos/hiramekun/TwitterSample/subscription","commits_url":"https://api.github.com/repos/hiramekun/TwitterSample/commits{/sha}","git_commits_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/commits{/sha}","comments_url":"https://api.github.com/repos/hiramekun/TwitterSample/comments{/number}","issue_comment_url":"https://api.github.com/repos/hiramekun/TwitterSample/issues/comments{/number}","contents_url":"https://api.github.com/repos/hiramekun/TwitterSample/contents/{+path}","compare_url":"https://api.github.com/repos/hiramekun/TwitterSample/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hiramekun/TwitterSample/merges","archive_url":"https://api.github.com/repos/hiramekun/TwitterSample/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hiramekun/TwitterSample/downloads","issues_url":"https://api.github.com/repos/hiramekun/TwitterSample/issues{/number}","pulls_url":"https://api.github.com/repos/hiramekun/TwitterSample/pulls{/number}","milestones_url":"https://api.github.com/repos/hiramekun/TwitterSample/milestones{/number}","notifications_url":"https://api.github.com/repos/hiramekun/TwitterSample/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hiramekun/TwitterSample/labels{/name}","releases_url":"https://api.github.com/repos/hiramekun/TwitterSample/releases{/id}","deployments_url":"https://api.github.com/repos/hiramekun/TwitterSample/deployments","created_at":"2017-05-13T01:21:49Z","updated_at":"2017-05-13T01:30:50Z","pushed_at":"2017-05-26T06:41:18Z","git_url":"git://github.com/hiramekun/TwitterSample.git","ssh_url":"git@github.com:hiramekun/TwitterSample.git","clone_url":"https://github.com/hiramekun/TwitterSample.git","svn_url":"https://github.com/hiramekun/TwitterSample","homepage":null,"size":2639,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"hiramekun:develop","ref":"develop","sha":"1e70c773869e91570bf9dd45d0291b4726018b08","user":{"login":"hiramekun","id":20180425,"avatar_url":"https://avatars2.githubusercontent.com/u/20180425?v=3","gravatar_id":"","url":"https://api.github.com/users/hiramekun","html_url":"https://github.com/hiramekun","followers_url":"https://api.github.com/users/hiramekun/followers","following_url":"https://api.github.com/users/hiramekun/following{/other_user}","gists_url":"https://api.github.com/users/hiramekun/gists{/gist_id}","starred_url":"https://api.github.com/users/hiramekun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiramekun/subscriptions","organizations_url":"https://api.github.com/users/hiramekun/orgs","repos_url":"https://api.github.com/users/hiramekun/repos","events_url":"https://api.github.com/users/hiramekun/events{/privacy}","received_events_url":"https://api.github.com/users/hiramekun/received_events","type":"User","site_admin":false},"repo":{"id":91140987,"name":"TwitterSample","full_name":"hiramekun/TwitterSample","owner":{"login":"hiramekun","id":20180425,"avatar_url":"https://avatars2.githubusercontent.com/u/20180425?v=3","gravatar_id":"","url":"https://api.github.com/users/hiramekun","html_url":"https://github.com/hiramekun","followers_url":"https://api.github.com/users/hiramekun/followers","following_url":"https://api.github.com/users/hiramekun/following{/other_user}","gists_url":"https://api.github.com/users/hiramekun/gists{/gist_id}","starred_url":"https://api.github.com/users/hiramekun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiramekun/subscriptions","organizations_url":"https://api.github.com/users/hiramekun/orgs","repos_url":"https://api.github.com/users/hiramekun/repos","events_url":"https://api.github.com/users/hiramekun/events{/privacy}","received_events_url":"https://api.github.com/users/hiramekun/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hiramekun/TwitterSample","description":"RxとRealmの練習","fork":false,"url":"https://api.github.com/repos/hiramekun/TwitterSample","forks_url":"https://api.github.com/repos/hiramekun/TwitterSample/forks","keys_url":"https://api.github.com/repos/hiramekun/TwitterSample/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hiramekun/TwitterSample/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hiramekun/TwitterSample/teams","hooks_url":"https://api.github.com/repos/hiramekun/TwitterSample/hooks","issue_events_url":"https://api.github.com/repos/hiramekun/TwitterSample/issues/events{/number}","events_url":"https://api.github.com/repos/hiramekun/TwitterSample/events","assignees_url":"https://api.github.com/repos/hiramekun/TwitterSample/assignees{/user}","branches_url":"https://api.github.com/repos/hiramekun/TwitterSample/branches{/branch}","tags_url":"https://api.github.com/repos/hiramekun/TwitterSample/tags","blobs_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/refs{/sha}","trees_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hiramekun/TwitterSample/statuses/{sha}","languages_url":"https://api.github.com/repos/hiramekun/TwitterSample/languages","stargazers_url":"https://api.github.com/repos/hiramekun/TwitterSample/stargazers","contributors_url":"https://api.github.com/repos/hiramekun/TwitterSample/contributors","subscribers_url":"https://api.github.com/repos/hiramekun/TwitterSample/subscribers","subscription_url":"https://api.github.com/repos/hiramekun/TwitterSample/subscription","commits_url":"https://api.github.com/repos/hiramekun/TwitterSample/commits{/sha}","git_commits_url":"https://api.github.com/repos/hiramekun/TwitterSample/git/commits{/sha}","comments_url":"https://api.github.com/repos/hiramekun/TwitterSample/comments{/number}","issue_comment_url":"https://api.github.com/repos/hiramekun/TwitterSample/issues/comments{/number}","contents_url":"https://api.github.com/repos/hiramekun/TwitterSample/contents/{+path}","compare_url":"https://api.github.com/repos/hiramekun/TwitterSample/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hiramekun/TwitterSample/merges","archive_url":"https://api.github.com/repos/hiramekun/TwitterSample/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hiramekun/TwitterSample/downloads","issues_url":"https://api.github.com/repos/hiramekun/TwitterSample/issues{/number}","pulls_url":"https://api.github.com/repos/hiramekun/TwitterSample/pulls{/number}","milestones_url":"https://api.github.com/repos/hiramekun/TwitterSample/milestones{/number}","notifications_url":"https://api.github.com/repos/hiramekun/TwitterSample/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hiramekun/TwitterSample/labels{/name}","releases_url":"https://api.github.com/repos/hiramekun/TwitterSample/releases{/id}","deployments_url":"https://api.github.com/repos/hiramekun/TwitterSample/deployments","created_at":"2017-05-13T01:21:49Z","updated_at":"2017-05-13T01:30:50Z","pushed_at":"2017-05-26T06:41:18Z","git_url":"git://github.com/hiramekun/TwitterSample.git","ssh_url":"git@github.com:hiramekun/TwitterSample.git","clone_url":"https://github.com/hiramekun/TwitterSample.git","svn_url":"https://github.com/hiramekun/TwitterSample","homepage":null,"size":2639,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/10"},"html":{"href":"https://github.com/hiramekun/TwitterSample/pull/10"},"issue":{"href":"https://api.github.com/repos/hiramekun/TwitterSample/issues/10"},"comments":{"href":"https://api.github.com/repos/hiramekun/TwitterSample/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hiramekun/TwitterSample/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/hiramekun/TwitterSample/statuses/6d9705dcbd97031c5981ea4f15bbc712c3e22318"}}}}
{"actor":{"display_login":"yukitoto"}}