{"action":"created","issue":{"url":"https://api.github.com/repos/paldepind/flyd-every/issues/1","labels_url":"https://api.github.com/repos/paldepind/flyd-every/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/paldepind/flyd-every/issues/1/comments","events_url":"https://api.github.com/repos/paldepind/flyd-every/issues/1/events","html_url":"https://github.com/paldepind/flyd-every/issues/1","id":79202969,"number":1,"title":"Does not handle active/inactive tabs appropriately","user":{"login":"theadam","id":850881,"avatar_url":"https://avatars.githubusercontent.com/u/850881?v=3","gravatar_id":"","url":"https://api.github.com/users/theadam","html_url":"https://github.com/theadam","followers_url":"https://api.github.com/users/theadam/followers","following_url":"https://api.github.com/users/theadam/following{/other_user}","gists_url":"https://api.github.com/users/theadam/gists{/gist_id}","starred_url":"https://api.github.com/users/theadam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theadam/subscriptions","organizations_url":"https://api.github.com/users/theadam/orgs","repos_url":"https://api.github.com/users/theadam/repos","events_url":"https://api.github.com/users/theadam/events{/privacy}","received_events_url":"https://api.github.com/users/theadam/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/paldepind/flyd-every/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-21T23:28:48Z","updated_at":"2015-05-22T15:04:07Z","closed_at":null,"body":"When in an inactive tab, timeouts are fired at most once per second.  [See this document](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout#Inactive_tabs).  \r\n\r\nDue to the way the next timeout is calculated inside flyd-every, this action can cause problems.  This is not the easiest thing to recreate but [here is some code to try out](http://requirebin.com/?gist=c690ce93158a6294096d).  Open your console, watch the events being logged.  Change to another tab for a while (the longer the better, but even a few seconds will be enough to witness the issue).  Once you change back to the running application, the stream will fire many events in a row.  The setTimeout calls were being called at most one second, but the math was expecting them to be called every 500ms.  This causes setTimeout to be called with negative numbers."},"comment":{"url":"https://api.github.com/repos/paldepind/flyd-every/issues/comments/104683109","html_url":"https://github.com/paldepind/flyd-every/issues/1#issuecomment-104683109","issue_url":"https://api.github.com/repos/paldepind/flyd-every/issues/1","id":104683109,"user":{"login":"paldepind","id":521604,"avatar_url":"https://avatars.githubusercontent.com/u/521604?v=3","gravatar_id":"","url":"https://api.github.com/users/paldepind","html_url":"https://github.com/paldepind","followers_url":"https://api.github.com/users/paldepind/followers","following_url":"https://api.github.com/users/paldepind/following{/other_user}","gists_url":"https://api.github.com/users/paldepind/gists{/gist_id}","starred_url":"https://api.github.com/users/paldepind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paldepind/subscriptions","organizations_url":"https://api.github.com/users/paldepind/orgs","repos_url":"https://api.github.com/users/paldepind/repos","events_url":"https://api.github.com/users/paldepind/events{/privacy}","received_events_url":"https://api.github.com/users/paldepind/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T15:04:06Z","updated_at":"2015-05-22T15:04:06Z","body":"If you want to do something on each frame then using `requestAnimationFrame` is appropriate.\r\n\r\nIf you want to do something like spawn an enemy every 5 seconds then flyd-every does the job. And in that case you don't want the user to prevent enemy spawning by switching frame and coming back.\r\n\r\nBut maybe keeping a lower limit on how fast the stream emits would be appropriate? Like, if a user request an update every second then never emit faster than half a second to keep up."}}