Closed benneq closed 7 years ago
What do you think about broadcasting a global event?
Something like
// to broadcast the event (has to be implemented in ng-stomp
$rootScope.$broadcast('stompConnected');
// And then to receive, use the $scope of your controller:
$scope.$on('stompConnected', function(event, args) {
// do what you want to do
});
Would this suite your use case?
I've already written my own ng-stomp alternative using RxJs.
There you can call subscribe
with or without connect
and it will automatically subscribe to all destinations when connection has been established. Though it doesn't matter if connecting takes a while.
Nevertheless thank you for this tool. Did help me a lot to look at your source code!
hello,
my localserver with stomp(spring project) is running on 8080 port. I am trying to connect it with my angular code. But I am getting following error.
beevelop.github.io/:1 XMLHttpRequest cannot load http://localhost:8080/info. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://beevelop.github.io' is therefore not allowed access. The response had HTTP status code 404.
Why its not connecting wiht localserver?
Can you please look into it?
@gibbsvjy007 This issue is caused by your server configuration. You need to add proper CORS headers and whitelist http://beevelop.github.io in order to use the Stomp UI. Please open a separate issue if you are still experiencing the described problem.
Hi, I've got following simple scenario / problem:
On application start I call
.connect(..)
at global scope, because I just need a single Stomp Connection for the whole application.At the same time Angular loads the first controller. And this controller needs to call
.subscribe(..)
and.send(..)
.The 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.In 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?So 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.Or maybe there's some other solution? Thank you!