{"action":"created","issue":{"url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/171","labels_url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/171/comments","events_url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/171/events","html_url":"https://github.com/tejasmanohar/node-schedule/pull/171","id":96627935,"number":171,"title":"Added support for optional callback when scheduled jobs are done","user":{"login":"seripap","id":683200,"avatar_url":"https://avatars.githubusercontent.com/u/683200?v=3","gravatar_id":"","url":"https://api.github.com/users/seripap","html_url":"https://github.com/seripap","followers_url":"https://api.github.com/users/seripap/followers","following_url":"https://api.github.com/users/seripap/following{/other_user}","gists_url":"https://api.github.com/users/seripap/gists{/gist_id}","starred_url":"https://api.github.com/users/seripap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seripap/subscriptions","organizations_url":"https://api.github.com/users/seripap/orgs","repos_url":"https://api.github.com/users/seripap/repos","events_url":"https://api.github.com/users/seripap/events{/privacy}","received_events_url":"https://api.github.com/users/seripap/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-07-22T17:57:42Z","updated_at":"2015-07-24T08:31:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/171","html_url":"https://github.com/tejasmanohar/node-schedule/pull/171","diff_url":"https://github.com/tejasmanohar/node-schedule/pull/171.diff","patch_url":"https://github.com/tejasmanohar/node-schedule/pull/171.patch"},"body":"I added support for an optional callback to be fired if provided when **job** is completed- just an extension of ``Job``. \r\n\r\nI also wasn't quite sure for the reason of this block:\r\n\r\n```javascript\r\nvar arg;\r\nfor (var i = 0; i < arguments.length; i++) {\r\n   arg = arguments[i];\r\n    if (typeof arg == 'string' || arg instanceof String) {\r\n      name = arg;\r\n    } else {\r\n      this.job = arg;\r\n    }\r\n  }\r\n```\r\n\r\nInstead of accessing the arguments obj, I just pass in the parameters to the class directly, to allow for more flexibility and removing the loop. If there was a reason, feel free to stop me and explain the method to the madness.\r\n\r\nCheers."},"comment":{"url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/comments/124441048","html_url":"https://github.com/tejasmanohar/node-schedule/pull/171#issuecomment-124441048","issue_url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/171","id":124441048,"user":{"login":"santigimeno","id":1084056,"avatar_url":"https://avatars.githubusercontent.com/u/1084056?v=3","gravatar_id":"","url":"https://api.github.com/users/santigimeno","html_url":"https://github.com/santigimeno","followers_url":"https://api.github.com/users/santigimeno/followers","following_url":"https://api.github.com/users/santigimeno/following{/other_user}","gists_url":"https://api.github.com/users/santigimeno/gists{/gist_id}","starred_url":"https://api.github.com/users/santigimeno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/santigimeno/subscriptions","organizations_url":"https://api.github.com/users/santigimeno/orgs","repos_url":"https://api.github.com/users/santigimeno/repos","events_url":"https://api.github.com/users/santigimeno/events{/privacy}","received_events_url":"https://api.github.com/users/santigimeno/received_events","type":"User","site_admin":false},"created_at":"2015-07-24T08:31:48Z","updated_at":"2015-07-24T08:31:48Z","body":"@seripap thanks for answering, but I still fail to understand the need of a callback :(. I'm sure I'm missing something obvious: could you please write a very basic example implementing the stop functionality you're referring to?\r\nOne more thing: how do you define that a job is done taking into account that a job can be sync or async?"}}