{"action":"created","issue":{"url":"https://api.github.com/repos/IceCreamYou/MainLoop.js/issues/5","repository_url":"https://api.github.com/repos/IceCreamYou/MainLoop.js","labels_url":"https://api.github.com/repos/IceCreamYou/MainLoop.js/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/IceCreamYou/MainLoop.js/issues/5/comments","events_url":"https://api.github.com/repos/IceCreamYou/MainLoop.js/issues/5/events","html_url":"https://github.com/IceCreamYou/MainLoop.js/issues/5","id":128411968,"number":5,"title":"Remove \"global\" library state","user":{"login":"jmeas","id":2322305,"avatar_url":"https://avatars.githubusercontent.com/u/2322305?v=3","gravatar_id":"","url":"https://api.github.com/users/jmeas","html_url":"https://github.com/jmeas","followers_url":"https://api.github.com/users/jmeas/followers","following_url":"https://api.github.com/users/jmeas/following{/other_user}","gists_url":"https://api.github.com/users/jmeas/gists{/gist_id}","starred_url":"https://api.github.com/users/jmeas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmeas/subscriptions","organizations_url":"https://api.github.com/users/jmeas/orgs","repos_url":"https://api.github.com/users/jmeas/repos","events_url":"https://api.github.com/users/jmeas/events{/privacy}","received_events_url":"https://api.github.com/users/jmeas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-01-24T17:27:27Z","updated_at":"2016-06-28T23:41:04Z","closed_at":null,"body":"This library only supports one instance per page due to the way it is written with global library state. A more idiomatic approach would be to expose a constructor that makes a new MainLoop. For instance,\r\n\r\n```js\r\nvar mainLoop = new MainLoop(options);\r\n\r\nmainLoop.setEnd(cb);\r\n\r\n// You can easily make another one\r\nvar mainLoopTwo = new MainLoop(options);\r\n```\r\n\r\nGiven how well-organized the code is, I think it'd be relatively simple to refactor it to use this system instead.\r\n\r\nIf this is something you're interested in, let me know and I'd be happy to put together a PR for you to review."},"comment":{"url":"https://api.github.com/repos/IceCreamYou/MainLoop.js/issues/comments/229216703","html_url":"https://github.com/IceCreamYou/MainLoop.js/issues/5#issuecomment-229216703","issue_url":"https://api.github.com/repos/IceCreamYou/MainLoop.js/issues/5","id":229216703,"user":{"login":"iwilliams","id":5215799,"avatar_url":"https://avatars.githubusercontent.com/u/5215799?v=3","gravatar_id":"","url":"https://api.github.com/users/iwilliams","html_url":"https://github.com/iwilliams","followers_url":"https://api.github.com/users/iwilliams/followers","following_url":"https://api.github.com/users/iwilliams/following{/other_user}","gists_url":"https://api.github.com/users/iwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/iwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iwilliams/subscriptions","organizations_url":"https://api.github.com/users/iwilliams/orgs","repos_url":"https://api.github.com/users/iwilliams/repos","events_url":"https://api.github.com/users/iwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/iwilliams/received_events","type":"User","site_admin":false},"created_at":"2016-06-28T23:41:04Z","updated_at":"2016-06-28T23:41:04Z","body":"I came here because I thought I had a use case, but as I type up my questions and ideas I find myself questioning the need for multiple loops....\r\n\r\nMy use case would be to run multiple simulations in a single node process for a multiplayer game, where each \"server\" would get its own loop. I was originally thinking that each server would need its own loop because you wouldn't want simulation ticks to slow down other people's games, but if all the loops are in the same process the time to process a tick is going to block the other loops if it takes too long anyway. Now what I'm thinking is in each update call I would just loop through all active instances and advance game logic for each one.\r\n\r\nI think that my use case is fundamentally similar to @bigsweater, but I find myself coming full circle to the original answer by @IceCreamYou. It seems to me that updating isolated states would be better managed in registered update function which I think is kind of the idea with the most recently proposed \"callback manager\" solution.\r\n\r\nI guess I don't really know where I'm going with this, but I wanted to get these ideas out there since I was considering doing the refactor to support multiple instances. "}}
{"actor":{"display_login":"iwilliams"}}