{"action":"closed","issue":{"url":"https://api.github.com/repos/beevelop/ng-stomp/issues/23","repository_url":"https://api.github.com/repos/beevelop/ng-stomp","labels_url":"https://api.github.com/repos/beevelop/ng-stomp/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/beevelop/ng-stomp/issues/23/comments","events_url":"https://api.github.com/repos/beevelop/ng-stomp/issues/23/events","html_url":"https://github.com/beevelop/ng-stomp/issues/23","id":211871448,"number":23,"title":"How to do call \".then(..)\" without \".connect(..)\" ?","user":{"login":"benneq","id":1627305,"avatar_url":"https://avatars1.githubusercontent.com/u/1627305?v=3","gravatar_id":"","url":"https://api.github.com/users/benneq","html_url":"https://github.com/benneq","followers_url":"https://api.github.com/users/benneq/followers","following_url":"https://api.github.com/users/benneq/following{/other_user}","gists_url":"https://api.github.com/users/benneq/gists{/gist_id}","starred_url":"https://api.github.com/users/benneq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benneq/subscriptions","organizations_url":"https://api.github.com/users/benneq/orgs","repos_url":"https://api.github.com/users/benneq/repos","events_url":"https://api.github.com/users/benneq/events{/privacy}","received_events_url":"https://api.github.com/users/benneq/received_events","type":"User","site_admin":false},"labels":[{"id":184510061,"url":"https://api.github.com/repos/beevelop/ng-stomp/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-03-04T10:33:28Z","updated_at":"2017-05-30T12:54:14Z","closed_at":"2017-05-30T12:54:14Z","body":"Hi,\r\nI've got following simple scenario / problem:\r\n\r\nOn application start I call `.connect(..)` at global scope, because I just need a single Stomp Connection for the whole application.\r\n\r\nAt the same time Angular loads the first controller. And this controller needs to call `.subscribe(..)` and `.send(..)`. \r\n\r\nThe problem is, that the connection takes some time to get established, but the controller code is running before `.connect(..)` has finished. And then It'll throw some Error.\r\n\r\nIn your example you use `.connect(..).then(..)`, but of course that's not possible, when calling `.connect(..)` at global scope. Or is it possible to call `.connect(..).then(..)` multiple times without creating multiple connections?\r\n\r\nSo it would be really nice to have some callbacks from you library, so I can call `.connect(..)` somewhere at application start. And then do something like `$stomp.onConnect(function(success) { if(success) { $stomp.subscribe(..) } });` or maybe use some promise for that.\r\n\r\nOr maybe there's some other solution? Thank you!"}}
{"actor":{"display_login":"beevelop"}}