{"action":"created","issue":{"url":"https://api.github.com/repos/yigit/android-priority-jobqueue/issues/82","labels_url":"https://api.github.com/repos/yigit/android-priority-jobqueue/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/yigit/android-priority-jobqueue/issues/82/comments","events_url":"https://api.github.com/repos/yigit/android-priority-jobqueue/issues/82/events","html_url":"https://github.com/yigit/android-priority-jobqueue/pull/82","id":126993984,"number":82,"title":"Feature Single-id to handle jobs that should only run once","user":{"login":"guavabot","id":6390457,"avatar_url":"https://avatars.githubusercontent.com/u/6390457?v=3","gravatar_id":"","url":"https://api.github.com/users/guavabot","html_url":"https://github.com/guavabot","followers_url":"https://api.github.com/users/guavabot/followers","following_url":"https://api.github.com/users/guavabot/following{/other_user}","gists_url":"https://api.github.com/users/guavabot/gists{/gist_id}","starred_url":"https://api.github.com/users/guavabot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guavabot/subscriptions","organizations_url":"https://api.github.com/users/guavabot/orgs","repos_url":"https://api.github.com/users/guavabot/repos","events_url":"https://api.github.com/users/guavabot/events{/privacy}","received_events_url":"https://api.github.com/users/guavabot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-01-16T02:10:53Z","updated_at":"2016-01-26T08:08:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/yigit/android-priority-jobqueue/pulls/82","html_url":"https://github.com/yigit/android-priority-jobqueue/pull/82","diff_url":"https://github.com/yigit/android-priority-jobqueue/pull/82.diff","patch_url":"https://github.com/yigit/android-priority-jobqueue/pull/82.patch"},"body":"This resolves path#51 and addresses part of what was requested in #36 .\r\n\r\nWhen building a job, you can pass a singleId Param, so that if another Job with the same singleId is already queued, they will only run once. This avoids having to manually use static atomic variables or other kinds of locks. It also improves from what was suggested in path#51 in that onAdded() will always be called, so you can do database operations in the JobManager's Executor (if using addJobInBackground). The feature covers the KEEP_OTHER scenario. \r\n\r\nSome details:\r\n- onAdded() will still be called on every Job so that you can update the local database if necessary. \r\n- The ID returned from addJob() will be the same for both (or more) jobs. \r\n- Finally, if the previous Job with the same singleId is already running, this behavior will not apply and both jobs will be run normally."},"comment":{"url":"https://api.github.com/repos/yigit/android-priority-jobqueue/issues/comments/174883958","html_url":"https://github.com/yigit/android-priority-jobqueue/pull/82#issuecomment-174883958","issue_url":"https://api.github.com/repos/yigit/android-priority-jobqueue/issues/82","id":174883958,"user":{"login":"guavabot","id":6390457,"avatar_url":"https://avatars.githubusercontent.com/u/6390457?v=3","gravatar_id":"","url":"https://api.github.com/users/guavabot","html_url":"https://github.com/guavabot","followers_url":"https://api.github.com/users/guavabot/followers","following_url":"https://api.github.com/users/guavabot/following{/other_user}","gists_url":"https://api.github.com/users/guavabot/gists{/gist_id}","starred_url":"https://api.github.com/users/guavabot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guavabot/subscriptions","organizations_url":"https://api.github.com/users/guavabot/orgs","repos_url":"https://api.github.com/users/guavabot/repos","events_url":"https://api.github.com/users/guavabot/events{/privacy}","received_events_url":"https://api.github.com/users/guavabot/received_events","type":"User","site_admin":false},"created_at":"2016-01-26T08:08:49Z","updated_at":"2016-01-26T08:08:49Z","body":"Looks good to me. At first I didn't like the idea of calling `onCancel` right after `onAdded`, but you're right that it makes sense for the Job's lifecycle. \r\n\r\nI'll do this during the week. Are the tests also good now?"}}