{"action":"created","issue":{"url":"https://api.github.com/repos/nrempel/adonis-scheduler/issues/1","repository_url":"https://api.github.com/repos/nrempel/adonis-scheduler","labels_url":"https://api.github.com/repos/nrempel/adonis-scheduler/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/nrempel/adonis-scheduler/issues/1/comments","events_url":"https://api.github.com/repos/nrempel/adonis-scheduler/issues/1/events","html_url":"https://github.com/nrempel/adonis-scheduler/issues/1","id":162559214,"number":1,"title":"Make handle method to a instance property instead of static","user":{"login":"thetutlage","id":1706381,"avatar_url":"https://avatars.githubusercontent.com/u/1706381?v=3","gravatar_id":"","url":"https://api.github.com/users/thetutlage","html_url":"https://github.com/thetutlage","followers_url":"https://api.github.com/users/thetutlage/followers","following_url":"https://api.github.com/users/thetutlage/following{/other_user}","gists_url":"https://api.github.com/users/thetutlage/gists{/gist_id}","starred_url":"https://api.github.com/users/thetutlage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thetutlage/subscriptions","organizations_url":"https://api.github.com/users/thetutlage/orgs","repos_url":"https://api.github.com/users/thetutlage/repos","events_url":"https://api.github.com/users/thetutlage/events{/privacy}","received_events_url":"https://api.github.com/users/thetutlage/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-06-27T22:04:34Z","updated_at":"2016-06-27T22:42:56Z","closed_at":null,"body":"Haven't tried it.\r\n\r\nBut by looking the example file https://github.com/nrempel/adonis-scheduler/blob/master/examples/app/Tasks/Example.js#L13 and the code, the `handle` method is a static property on the class, which simply defeats the purpose of creating a class.\r\n\r\nI would suggest to make it an instance property and `make` the task class instance using `Ioc.make` on this line https://github.com/nrempel/adonis-scheduler/blob/master/src/Scheduler/index.js#L40.\r\n\r\n## Benefits of Ioc.make\r\n\r\n`Ioc.make` will create an instance of class and will inject any dependencies that class wants. For example.\r\n\r\n```javascript\r\nclass RemoveDisabledUsers {\r\n\r\n  static get schedule() {\r\n    return '*/1 * * * *';\r\n  }\r\n\r\n   static get inject () {\r\n      return ['App/Model/User']\r\n   }\r\n\r\n   constructor (User) {\r\n     this.User = User\r\n   }\r\n\r\n  * handle () {\r\n     const removeUsers = yield this.User.query().where('status', 'disabled').delete()\r\n   }\r\n\r\n}\r\n\r\nmodule.exports = RemoveDisabledUsers;\r\n```\r\n\r\nAbove one is more helpful than having the `static handle`, coz I am able to inject my dependencies automatically.\r\n\r\nAlso wrap your `handle` method inside [co](https://www.npmjs.com/package/co). Which simply stays in the eco-system of AdonisJs by offering `ES2015` generators first approach."},"comment":{"url":"https://api.github.com/repos/nrempel/adonis-scheduler/issues/comments/228897961","html_url":"https://github.com/nrempel/adonis-scheduler/issues/1#issuecomment-228897961","issue_url":"https://api.github.com/repos/nrempel/adonis-scheduler/issues/1","id":228897961,"user":{"login":"nrempel","id":540048,"avatar_url":"https://avatars.githubusercontent.com/u/540048?v=3","gravatar_id":"","url":"https://api.github.com/users/nrempel","html_url":"https://github.com/nrempel","followers_url":"https://api.github.com/users/nrempel/followers","following_url":"https://api.github.com/users/nrempel/following{/other_user}","gists_url":"https://api.github.com/users/nrempel/gists{/gist_id}","starred_url":"https://api.github.com/users/nrempel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrempel/subscriptions","organizations_url":"https://api.github.com/users/nrempel/orgs","repos_url":"https://api.github.com/users/nrempel/repos","events_url":"https://api.github.com/users/nrempel/events{/privacy}","received_events_url":"https://api.github.com/users/nrempel/received_events","type":"User","site_admin":false},"created_at":"2016-06-27T22:42:56Z","updated_at":"2016-06-27T22:42:56Z","body":"Thanks for the feedback!\r\n\r\nI was fumbling a bit trying to come up with an idiomatic approach so this helps.\r\n\r\nI'll make improvements soon."}}
{"actor":{"display_login":"nrempel"}}