{"action":"created","issue":{"url":"https://api.github.com/repos/jonashagstedt/swampdragon/issues/29","labels_url":"https://api.github.com/repos/jonashagstedt/swampdragon/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/jonashagstedt/swampdragon/issues/29/comments","events_url":"https://api.github.com/repos/jonashagstedt/swampdragon/issues/29/events","html_url":"https://github.com/jonashagstedt/swampdragon/issues/29","id":59307777,"number":29,"title":"swampdragon.ready functions re-executing after dropped connection is reestablished","user":{"login":"griphiam","id":46191,"avatar_url":"https://avatars.githubusercontent.com/u/46191?v=3","gravatar_id":"","url":"https://api.github.com/users/griphiam","html_url":"https://github.com/griphiam","followers_url":"https://api.github.com/users/griphiam/followers","following_url":"https://api.github.com/users/griphiam/following{/other_user}","gists_url":"https://api.github.com/users/griphiam/gists{/gist_id}","starred_url":"https://api.github.com/users/griphiam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/griphiam/subscriptions","organizations_url":"https://api.github.com/users/griphiam/orgs","repos_url":"https://api.github.com/users/griphiam/repos","events_url":"https://api.github.com/users/griphiam/events{/privacy}","received_events_url":"https://api.github.com/users/griphiam/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-27T23:06:34Z","updated_at":"2015-02-28T23:38:25Z","closed_at":"2015-02-28T23:38:25Z","body":"functions passed to the sampdragon.ready function end up being bound the the connection's 'open' signal.  If the connection is lost and then restablished, all those functions are still bound to the 'open' signal and are called again.  For subscribe methods, it makes sense to call the subscribe again to reestablish the link.\r\n\r\nHowever all callRouter calls are called again (even non-subscribe) and they shouldn't be because they were probably a call once sort of method.\r\n\r\nWould it make sense to have two different flavors of a ready function (one that should be called again if the connection is lost and regained) and another that deregisters the callback once it's been called?"},"comment":{"url":"https://api.github.com/repos/jonashagstedt/swampdragon/issues/comments/76557202","html_url":"https://github.com/jonashagstedt/swampdragon/issues/29#issuecomment-76557202","issue_url":"https://api.github.com/repos/jonashagstedt/swampdragon/issues/29","id":76557202,"user":{"login":"jonashagstedt","id":603835,"avatar_url":"https://avatars.githubusercontent.com/u/603835?v=3","gravatar_id":"","url":"https://api.github.com/users/jonashagstedt","html_url":"https://github.com/jonashagstedt","followers_url":"https://api.github.com/users/jonashagstedt/followers","following_url":"https://api.github.com/users/jonashagstedt/following{/other_user}","gists_url":"https://api.github.com/users/jonashagstedt/gists{/gist_id}","starred_url":"https://api.github.com/users/jonashagstedt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonashagstedt/subscriptions","organizations_url":"https://api.github.com/users/jonashagstedt/orgs","repos_url":"https://api.github.com/users/jonashagstedt/repos","events_url":"https://api.github.com/users/jonashagstedt/events{/privacy}","received_events_url":"https://api.github.com/users/jonashagstedt/received_events","type":"User","site_admin":false},"created_at":"2015-02-28T23:38:25Z","updated_at":"2015-02-28T23:38:25Z","body":"Slight change as I came across a few things digging in to the code and saw some room for improvement:\r\n\r\nThere are two new functions:\r\n\r\n`open`: will execute every time the connection is opened (good place for subscribe calls)\r\n`close`: will execute every time the connection is closed (good place to disable user inputs etc)\r\n\r\n`ready` will only trigger once, despite the connection going up and down."}}