{"action":"created","issue":{"url":"https://api.github.com/repos/Corsaair/redtamarin/issues/83","repository_url":"https://api.github.com/repos/Corsaair/redtamarin","labels_url":"https://api.github.com/repos/Corsaair/redtamarin/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/Corsaair/redtamarin/issues/83/comments","events_url":"https://api.github.com/repos/Corsaair/redtamarin/issues/83/events","html_url":"https://github.com/Corsaair/redtamarin/issues/83","id":143123820,"number":83,"title":"natime timer callback","user":{"login":"zwetan","id":236154,"avatar_url":"https://avatars.githubusercontent.com/u/236154?v=3","gravatar_id":"","url":"https://api.github.com/users/zwetan","html_url":"https://github.com/zwetan","followers_url":"https://api.github.com/users/zwetan/followers","following_url":"https://api.github.com/users/zwetan/following{/other_user}","gists_url":"https://api.github.com/users/zwetan/gists{/gist_id}","starred_url":"https://api.github.com/users/zwetan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zwetan/subscriptions","organizations_url":"https://api.github.com/users/zwetan/orgs","repos_url":"https://api.github.com/users/zwetan/repos","events_url":"https://api.github.com/users/zwetan/events{/privacy}","received_events_url":"https://api.github.com/users/zwetan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-24T01:50:40Z","updated_at":"2016-03-24T02:14:24Z","closed_at":null,"body":"based on [Platform.h](https://github.com/Corsaair/redtamarin/blob/master/src/shell/Platform.h) interface\r\n```cpp\r\n    /**\r\n    * function pointer for the timer callback function\r\n    * @see setTimer()\r\n    */\r\n    typedef void (*AvmTimerCallback)(void*);\r\n\r\n    class Platform\r\n    {\r\n    public:\r\n        /**\r\n        * Method to set a platform-specific timer for a callback after specific interval of time\r\n        * This method should implement a one-shot timer\r\n        * @param seconds number of seconds indicating the timer expiration\r\n        * @param callback function that will be invoked when the timer fires\r\n        * @param callbackData context data that will be passed as an argument during \"callback\" invocation\r\n        * @return none\r\n        */\r\n        virtual void setTimer(int seconds, AvmTimerCallback callback, void* callbackData) = 0;\r\n    };\r\n```\r\n\r\nimplement a `_setTimerListener` that works like `_setExitListener`\r\n\r\neg.\r\n```as3\r\nprivate native static function _setTimerListener( seconds:int, f:Function ):void;\r\n\r\nAVM2 static function setTimerListener( seconds:int, f:Function ):void\r\n{\r\n    _setTimerListener( seconds, f );\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Corsaair/redtamarin/issues/comments/200618911","html_url":"https://github.com/Corsaair/redtamarin/issues/83#issuecomment-200618911","issue_url":"https://api.github.com/repos/Corsaair/redtamarin/issues/83","id":200618911,"user":{"login":"zwetan","id":236154,"avatar_url":"https://avatars.githubusercontent.com/u/236154?v=3","gravatar_id":"","url":"https://api.github.com/users/zwetan","html_url":"https://github.com/zwetan","followers_url":"https://api.github.com/users/zwetan/followers","following_url":"https://api.github.com/users/zwetan/following{/other_user}","gists_url":"https://api.github.com/users/zwetan/gists{/gist_id}","starred_url":"https://api.github.com/users/zwetan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zwetan/subscriptions","organizations_url":"https://api.github.com/users/zwetan/orgs","repos_url":"https://api.github.com/users/zwetan/repos","events_url":"https://api.github.com/users/zwetan/events{/privacy}","received_events_url":"https://api.github.com/users/zwetan/received_events","type":"User","site_admin":false},"created_at":"2016-03-24T02:14:24Z","updated_at":"2016-03-24T02:14:24Z","body":"this `setTimerListener ` need to deal with only one listener function\r\n\r\nif passed `null` it should destroy the timer listener\r\n\r\nif passed another function (while one is already set) should override the current function\r\n\r\nif passed only a `seconds` argument\r\n  - if function already exists, override the seconds with the new seconds arg\r\n    eg. should allow to change the \"timing\" at runtime\r\n  - if function does not exists, do nothing\r\n\r\nexample:\r\n```as3\r\nfunction myLoop():void\r\n{\r\n    // some loop\r\n}\r\n\r\nProgram. setTimerListener( 10, myLoop ); //loop every 10sec\r\n\r\nProgram. setTimerListener( 30 ); //override, now function loop every 30sec\r\n```"}}