{"action":"created","comment":{"url":"https://api.github.com/repos/novoda/spikes/pulls/comments/70405577","id":70405577,"diff_hunk":"@@ -101,46 +121,30 @@ public Tasks apply(Tasks input) {\n         };\n     }\n \n-    private Observable<Event<Tasks>> initialiseSubject() {\n-        return Observable.defer(new Func0<Observable<Event<Tasks>>>() {\n-            @Override\n-            public Observable<Event<Tasks>> call() {\n-                if (isInitialised(taskRelay)) {\n-                    return Observable.empty();\n-                }\n-                return localDataSource.getTasks()\n-                        .flatMap(fetchFromRemoteIfOutOfDate())\n-                        .switchIfEmpty(fetchFromRemote())\n-                        .compose(asValidatedEvent(taskRelay.getValue()))\n-                        .doOnNext(taskRelay)\n-                        .publish().autoConnect();\n-            }\n-        });\n-    }\n-\n-    private Func1<Tasks, Observable<Tasks>> fetchFromRemoteIfOutOfDate() {\n+    private Func1<Tasks, Observable<Tasks>> fetchFromRemoteIfOutOfDate(final long actionTimeInMillis) {\n         return new Func1<Tasks, Observable<Tasks>>() {\n             @Override\n             public Observable<Tasks> call(Tasks tasks) {\n                 if (tasksDataFreshnessChecker.isFresh(tasks)) {\n                     return Observable.just(tasks);","path":"Architecture/TodoApp/android/core/src/main/java/com/novoda/todoapp/tasks/service/PersistedTasksService.java","position":91,"original_position":91,"commit_id":"db5495353bff6afc2e4cac8534544e28c6bb20e7","original_commit_id":"db5495353bff6afc2e4cac8534544e28c6bb20e7","user":{"login":"Mecharyry","id":3380092,"avatar_url":"https://avatars.githubusercontent.com/u/3380092?v=3","gravatar_id":"","url":"https://api.github.com/users/Mecharyry","html_url":"https://github.com/Mecharyry","followers_url":"https://api.github.com/users/Mecharyry/followers","following_url":"https://api.github.com/users/Mecharyry/following{/other_user}","gists_url":"https://api.github.com/users/Mecharyry/gists{/gist_id}","starred_url":"https://api.github.com/users/Mecharyry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mecharyry/subscriptions","organizations_url":"https://api.github.com/users/Mecharyry/orgs","repos_url":"https://api.github.com/users/Mecharyry/repos","events_url":"https://api.github.com/users/Mecharyry/events{/privacy}","received_events_url":"https://api.github.com/users/Mecharyry/received_events","type":"User","site_admin":false},"body":"Could you do:\r\n\r\n```\r\n        localDataSource.getTasks()\r\n                .filter(new Func1<List<Integer>, Boolean>() {\r\n                    @Override\r\n                    public Boolean call(List<Integer> integers) {\r\n                        return tasksDataFreshnessChecker.isFresh(tasks);\r\n                    }\r\n                })\r\n                .switchIfEmpty(fetchFromRemote(actionTimeInMillis))\r\n                .compose(asValidatedEvent(taskRelay.getValue()))\r\n                .subscribeOn(scheduler)\r\n                .subscribe(taskRelay);\r\n```\r\nOr have I missed something? 👅 ","created_at":"2016-07-12T09:32:16Z","updated_at":"2016-07-12T09:32:16Z","html_url":"https://github.com/novoda/spikes/pull/139#discussion_r70405577","pull_request_url":"https://api.github.com/repos/novoda/spikes/pulls/139","_links":{"self":{"href":"https://api.github.com/repos/novoda/spikes/pulls/comments/70405577"},"html":{"href":"https://github.com/novoda/spikes/pull/139#discussion_r70405577"},"pull_request":{"href":"https://api.github.com/repos/novoda/spikes/pulls/139"}}},"pull_request":{"url":"https://api.github.com/repos/novoda/spikes/pulls/139","id":76965616,"html_url":"https://github.com/novoda/spikes/pull/139","diff_url":"https://github.com/novoda/spikes/pull/139.diff","patch_url":"https://github.com/novoda/spikes/pull/139.patch","issue_url":"https://api.github.com/repos/novoda/spikes/issues/139","number":139,"state":"open","locked":false,"title":"Avoid Updating the tasks when the value is outdated.","user":{"login":"Dorvaryn","id":610924,"avatar_url":"https://avatars.githubusercontent.com/u/610924?v=3","gravatar_id":"","url":"https://api.github.com/users/Dorvaryn","html_url":"https://github.com/Dorvaryn","followers_url":"https://api.github.com/users/Dorvaryn/followers","following_url":"https://api.github.com/users/Dorvaryn/following{/other_user}","gists_url":"https://api.github.com/users/Dorvaryn/gists{/gist_id}","starred_url":"https://api.github.com/users/Dorvaryn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dorvaryn/subscriptions","organizations_url":"https://api.github.com/users/Dorvaryn/orgs","repos_url":"https://api.github.com/users/Dorvaryn/repos","events_url":"https://api.github.com/users/Dorvaryn/events{/privacy}","received_events_url":"https://api.github.com/users/Dorvaryn/received_events","type":"User","site_admin":false},"body":"#### Problem\r\nWhen clearing the completed tasks, if there was a task marked as completed just before we could sometime have the task reappearing as the reply form the sever would override the local state.\r\n\r\n#### Solution\r\nWe can mark the timestamp of the clearCompleted tasks action and avoid any updates when timestamps are not showing we are the most recent action.\r\nTo achieve this a few other refactoring were needed to simplify the code, one notable one is the addition of the scheduler inside the service. This allows for finer grain concurrency decisions in the domain that single threaded actions could not achieve.\r\n\r\n##### Test(s) added \r\n_yes_ - `PersistedTasksService` now has tests covering updates when calling `clearCompletedTasks`\r\n\r\n##### Screenshots\r\n| Before | After |\r\n| ------ | ----- |\r\n|![before](https://cloud.githubusercontent.com/assets/610924/16734549/dbc966f6-477d-11e6-9349-3c45149feb3c.gif)|![after](https://cloud.githubusercontent.com/assets/610924/16734548/dbc8180a-477d-11e6-9889-4bb74e1b6205.gif)|\r\n\r\n\r\n###### Paired with \r\nNo-one","created_at":"2016-07-11T14:41:39Z","updated_at":"2016-07-12T09:32:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4bcc53115dd44503f70f432b203d0f38938fbbc3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/novoda/spikes/pulls/139/commits","review_comments_url":"https://api.github.com/repos/novoda/spikes/pulls/139/comments","review_comment_url":"https://api.github.com/repos/novoda/spikes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/novoda/spikes/issues/139/comments","statuses_url":"https://api.github.com/repos/novoda/spikes/statuses/db5495353bff6afc2e4cac8534544e28c6bb20e7","head":{"label":"novoda:architecture/feature/drop_updates_if_outdated","ref":"architecture/feature/drop_updates_if_outdated","sha":"db5495353bff6afc2e4cac8534544e28c6bb20e7","user":{"login":"novoda","id":74874,"avatar_url":"https://avatars.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"repo":{"id":13300550,"name":"spikes","full_name":"novoda/spikes","owner":{"login":"novoda","id":74874,"avatar_url":"https://avatars.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/novoda/spikes","description":"Where ideas & concepts are born & incubated","fork":false,"url":"https://api.github.com/repos/novoda/spikes","forks_url":"https://api.github.com/repos/novoda/spikes/forks","keys_url":"https://api.github.com/repos/novoda/spikes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/novoda/spikes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/novoda/spikes/teams","hooks_url":"https://api.github.com/repos/novoda/spikes/hooks","issue_events_url":"https://api.github.com/repos/novoda/spikes/issues/events{/number}","events_url":"https://api.github.com/repos/novoda/spikes/events","assignees_url":"https://api.github.com/repos/novoda/spikes/assignees{/user}","branches_url":"https://api.github.com/repos/novoda/spikes/branches{/branch}","tags_url":"https://api.github.com/repos/novoda/spikes/tags","blobs_url":"https://api.github.com/repos/novoda/spikes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/novoda/spikes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/novoda/spikes/git/refs{/sha}","trees_url":"https://api.github.com/repos/novoda/spikes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/novoda/spikes/statuses/{sha}","languages_url":"https://api.github.com/repos/novoda/spikes/languages","stargazers_url":"https://api.github.com/repos/novoda/spikes/stargazers","contributors_url":"https://api.github.com/repos/novoda/spikes/contributors","subscribers_url":"https://api.github.com/repos/novoda/spikes/subscribers","subscription_url":"https://api.github.com/repos/novoda/spikes/subscription","commits_url":"https://api.github.com/repos/novoda/spikes/commits{/sha}","git_commits_url":"https://api.github.com/repos/novoda/spikes/git/commits{/sha}","comments_url":"https://api.github.com/repos/novoda/spikes/comments{/number}","issue_comment_url":"https://api.github.com/repos/novoda/spikes/issues/comments{/number}","contents_url":"https://api.github.com/repos/novoda/spikes/contents/{+path}","compare_url":"https://api.github.com/repos/novoda/spikes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/novoda/spikes/merges","archive_url":"https://api.github.com/repos/novoda/spikes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/novoda/spikes/downloads","issues_url":"https://api.github.com/repos/novoda/spikes/issues{/number}","pulls_url":"https://api.github.com/repos/novoda/spikes/pulls{/number}","milestones_url":"https://api.github.com/repos/novoda/spikes/milestones{/number}","notifications_url":"https://api.github.com/repos/novoda/spikes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/novoda/spikes/labels{/name}","releases_url":"https://api.github.com/repos/novoda/spikes/releases{/id}","deployments_url":"https://api.github.com/repos/novoda/spikes/deployments","created_at":"2013-10-03T14:31:43Z","updated_at":"2016-07-12T03:50:29Z","pushed_at":"2016-07-12T09:30:19Z","git_url":"git://github.com/novoda/spikes.git","ssh_url":"git@github.com:novoda/spikes.git","clone_url":"https://github.com/novoda/spikes.git","svn_url":"https://github.com/novoda/spikes","homepage":"","size":31919,"stargazers_count":92,"watchers_count":92,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":3,"forks":12,"open_issues":3,"watchers":92,"default_branch":"master"}},"base":{"label":"novoda:architecture/develop","ref":"architecture/develop","sha":"144ed0b96c848e416f356c2f2f8806af5d34deb0","user":{"login":"novoda","id":74874,"avatar_url":"https://avatars.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"repo":{"id":13300550,"name":"spikes","full_name":"novoda/spikes","owner":{"login":"novoda","id":74874,"avatar_url":"https://avatars.githubusercontent.com/u/74874?v=3","gravatar_id":"","url":"https://api.github.com/users/novoda","html_url":"https://github.com/novoda","followers_url":"https://api.github.com/users/novoda/followers","following_url":"https://api.github.com/users/novoda/following{/other_user}","gists_url":"https://api.github.com/users/novoda/gists{/gist_id}","starred_url":"https://api.github.com/users/novoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novoda/subscriptions","organizations_url":"https://api.github.com/users/novoda/orgs","repos_url":"https://api.github.com/users/novoda/repos","events_url":"https://api.github.com/users/novoda/events{/privacy}","received_events_url":"https://api.github.com/users/novoda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/novoda/spikes","description":"Where ideas & concepts are born & incubated","fork":false,"url":"https://api.github.com/repos/novoda/spikes","forks_url":"https://api.github.com/repos/novoda/spikes/forks","keys_url":"https://api.github.com/repos/novoda/spikes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/novoda/spikes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/novoda/spikes/teams","hooks_url":"https://api.github.com/repos/novoda/spikes/hooks","issue_events_url":"https://api.github.com/repos/novoda/spikes/issues/events{/number}","events_url":"https://api.github.com/repos/novoda/spikes/events","assignees_url":"https://api.github.com/repos/novoda/spikes/assignees{/user}","branches_url":"https://api.github.com/repos/novoda/spikes/branches{/branch}","tags_url":"https://api.github.com/repos/novoda/spikes/tags","blobs_url":"https://api.github.com/repos/novoda/spikes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/novoda/spikes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/novoda/spikes/git/refs{/sha}","trees_url":"https://api.github.com/repos/novoda/spikes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/novoda/spikes/statuses/{sha}","languages_url":"https://api.github.com/repos/novoda/spikes/languages","stargazers_url":"https://api.github.com/repos/novoda/spikes/stargazers","contributors_url":"https://api.github.com/repos/novoda/spikes/contributors","subscribers_url":"https://api.github.com/repos/novoda/spikes/subscribers","subscription_url":"https://api.github.com/repos/novoda/spikes/subscription","commits_url":"https://api.github.com/repos/novoda/spikes/commits{/sha}","git_commits_url":"https://api.github.com/repos/novoda/spikes/git/commits{/sha}","comments_url":"https://api.github.com/repos/novoda/spikes/comments{/number}","issue_comment_url":"https://api.github.com/repos/novoda/spikes/issues/comments{/number}","contents_url":"https://api.github.com/repos/novoda/spikes/contents/{+path}","compare_url":"https://api.github.com/repos/novoda/spikes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/novoda/spikes/merges","archive_url":"https://api.github.com/repos/novoda/spikes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/novoda/spikes/downloads","issues_url":"https://api.github.com/repos/novoda/spikes/issues{/number}","pulls_url":"https://api.github.com/repos/novoda/spikes/pulls{/number}","milestones_url":"https://api.github.com/repos/novoda/spikes/milestones{/number}","notifications_url":"https://api.github.com/repos/novoda/spikes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/novoda/spikes/labels{/name}","releases_url":"https://api.github.com/repos/novoda/spikes/releases{/id}","deployments_url":"https://api.github.com/repos/novoda/spikes/deployments","created_at":"2013-10-03T14:31:43Z","updated_at":"2016-07-12T03:50:29Z","pushed_at":"2016-07-12T09:30:19Z","git_url":"git://github.com/novoda/spikes.git","ssh_url":"git@github.com:novoda/spikes.git","clone_url":"https://github.com/novoda/spikes.git","svn_url":"https://github.com/novoda/spikes","homepage":"","size":31919,"stargazers_count":92,"watchers_count":92,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":3,"forks":12,"open_issues":3,"watchers":92,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/novoda/spikes/pulls/139"},"html":{"href":"https://github.com/novoda/spikes/pull/139"},"issue":{"href":"https://api.github.com/repos/novoda/spikes/issues/139"},"comments":{"href":"https://api.github.com/repos/novoda/spikes/issues/139/comments"},"review_comments":{"href":"https://api.github.com/repos/novoda/spikes/pulls/139/comments"},"review_comment":{"href":"https://api.github.com/repos/novoda/spikes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/novoda/spikes/pulls/139/commits"},"statuses":{"href":"https://api.github.com/repos/novoda/spikes/statuses/db5495353bff6afc2e4cac8534544e28c6bb20e7"}}}}
{"actor":{"display_login":"Mecharyry"}}