{"action":"created","issue":{"url":"https://api.github.com/repos/VCVRack/Rack/issues/690","repository_url":"https://api.github.com/repos/VCVRack/Rack","labels_url":"https://api.github.com/repos/VCVRack/Rack/issues/690/labels{/name}","comments_url":"https://api.github.com/repos/VCVRack/Rack/issues/690/comments","events_url":"https://api.github.com/repos/VCVRack/Rack/issues/690/events","html_url":"https://github.com/VCVRack/Rack/issues/690","id":295749698,"number":690,"title":"Discussion: Hook for module initialization","user":{"login":"cschol","id":624427,"avatar_url":"https://avatars0.githubusercontent.com/u/624427?v=4","gravatar_id":"","url":"https://api.github.com/users/cschol","html_url":"https://github.com/cschol","followers_url":"https://api.github.com/users/cschol/followers","following_url":"https://api.github.com/users/cschol/following{/other_user}","gists_url":"https://api.github.com/users/cschol/gists{/gist_id}","starred_url":"https://api.github.com/users/cschol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cschol/subscriptions","organizations_url":"https://api.github.com/users/cschol/orgs","repos_url":"https://api.github.com/users/cschol/repos","events_url":"https://api.github.com/users/cschol/events{/privacy}","received_events_url":"https://api.github.com/users/cschol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-02-09T04:14:06Z","updated_at":"2018-02-09T15:38:47Z","closed_at":null,"author_association":"NONE","body":"My module has an `init()` function that initializes internal state from the settings saved to the patch file before the step function runs. It is only run once at module startup (or when the module is reinitialized).\r\n\r\nCurrently, I have put a one-shot at the top of the `step()` function to make this work. \r\n\r\nSomething like this:\r\n```\r\nvoid step() {\r\n    if (!inited_) {\r\n        init();\r\n        inited_ = true;\r\n    }\r\n[...]\r\n```\r\n\r\nIf I put `init()` in the module constructor, the parameters have not been read from the patch file yet.\r\nFor the re-init, I can use the `onReset()` hook to set `inited_` to `false` and reinitialized on the next step.\r\n\r\nAm I missing a hook that I could use for the initialization on startup that is executed after the parameters are available? Would a hook like `onInit()` make sense? \r\n\r\nTiming-wise, I would think for it to be called right after `moduleWidget->fromJson(moduleJ)` in `RackWidget()` (l.273).\r\n"},"comment":{"url":"https://api.github.com/repos/VCVRack/Rack/issues/comments/364468626","html_url":"https://github.com/VCVRack/Rack/issues/690#issuecomment-364468626","issue_url":"https://api.github.com/repos/VCVRack/Rack/issues/690","id":364468626,"user":{"login":"squinkylabs","id":16314838,"avatar_url":"https://avatars2.githubusercontent.com/u/16314838?v=4","gravatar_id":"","url":"https://api.github.com/users/squinkylabs","html_url":"https://github.com/squinkylabs","followers_url":"https://api.github.com/users/squinkylabs/followers","following_url":"https://api.github.com/users/squinkylabs/following{/other_user}","gists_url":"https://api.github.com/users/squinkylabs/gists{/gist_id}","starred_url":"https://api.github.com/users/squinkylabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squinkylabs/subscriptions","organizations_url":"https://api.github.com/users/squinkylabs/orgs","repos_url":"https://api.github.com/users/squinkylabs/repos","events_url":"https://api.github.com/users/squinkylabs/events{/privacy}","received_events_url":"https://api.github.com/users/squinkylabs/received_events","type":"User","site_admin":false},"created_at":"2018-02-09T15:38:47Z","updated_at":"2018-02-09T15:38:47Z","author_association":"NONE","body":"well, that makes things easier! nice."}}
{"actor":{"display_login":"squinkylabs"}}