Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freeze angular with subscribe #13

Closed
yabb85 opened this issue Feb 14, 2015 · 8 comments
Closed

freeze angular with subscribe #13

yabb85 opened this issue Feb 14, 2015 · 8 comments

Comments

@yabb85
Copy link

yabb85 commented Feb 14, 2015

Hi,

I use angular-wamp but i want to create a subscrite all page is not rendered.
Lines used to subscribe to event:

function refreshList(args) {
    console.log('toto');
}
$wamp.subscribe('refresh_add_product', refreshList);

renderd page with this code:
capture du 2015-02-14 13 31 51

redndered page with wamp.subscribe line commented:
capture du 2015-02-14 13 31 01

Best regards
Laurent

@davidwdan
Copy link
Member

What errors are you seeing in the browser's console?

@yabb85
Copy link
Author

yabb85 commented Feb 14, 2015

I have no eror message in browser's console.

All content of my console:
"session not open" angular.min.js:102

"Congrats! You're connected to the WAMP server!" angular.min.js:102
"We are connected to the WAMP Router!"

@davidwdan
Copy link
Member

Not much to go on there. Can you set a break point on that subscribe and then step through it. Angular doesn't display some exceptions when they're caught. If that doesn't give you anything, can you create a plunkr that reproduces the issue?

@yabb85
Copy link
Author

yabb85 commented Feb 15, 2015

I have a conflict between angular-wamp and http.get. I must inverted http.

my all code is:

var app = angular.module('myCart', ['vxWamp']);

app.config(function($wampProvider){
    $wampProvider.init({
        url: "ws://127.0.0.1:8080/ws",
        realm: "realm1"
    });
});


app.controller('courseCtrl', function($scope, $http, $wamp){

    $scope.id_list = window.location.pathname.split('/');
    $scope.id_list = $scope.id_list[$scope.id_list.length-1];

    /* Request to REST api */
    $http.get('/api/extended_list/1').success(function(data){
        $scope.bought = data.achats;
    }).
    error(function(data){
        console.log(data);
    });

    $http.get('/api/products/').success(function(data){
        $scope.items = data.products;
    }).
    error(function(data){
        console.log(data);
    });

    /* Wamp */
    //Executed at connection to wamp server
    $scope.$on("$wamp.open", function (event, session) {
        console.log('We are connected to the WAMP Router!'); 
    });

    //Executed after loose or close connection with wamp server
    $scope.$on("$wamp.close", function (event, data) {
        $scope.reason = data.reason;
        $scope.details = data.details;
    });

    function refreshList(args) {
        console.log('toto');
    }
    $wamp.subscribe('refresh_add_product', refreshList);

    /* Action */
    $scope.addToCart = function(id){
        $wamp.call('me.hory.add_to_list', [id, $scope.id_list]).then(
            function(res){
                console.log('product added to list');
            },
            function(error){
                console.log('impossible to add product in list');
            }
        );
    }

    $scope.removeToCart = function(id){
        $wamp.call('me.hory.remove_to_list', [id, $scope.id_list]).then(
            function(res){
                console.log('product removed to list');
            },
            function(error){
                console.log('impossible to remove product in list');
            }
        );
    }

});

app.run(function($wamp){
    $wamp.open();
})

@davidwdan
Copy link
Member

@yabb85 Are you saying that you had a conflict between angular-wamp and $http.get, but it's fixed now? Or are you still having issues?

@yabb85
Copy link
Author

yabb85 commented Feb 21, 2015

I don't understand.
If i use a break point this code is ok.
But without break point the page is not correctly displayed and i don't have an error in console.

@davidwdan
Copy link
Member

It sounds like you might have some sort of race condition. Can you recreate the issue with a plunker?

@yabb85
Copy link
Author

yabb85 commented Mar 15, 2015

Hi,
I have created a plunk at address: http://plnkr.co/edit/ChQKyoWkHdc1I2PFXw5o?p=linter
But with this plunker I have no issue.
The problem is my version of file autobahn.min.js

Thanks for help

@yabb85 yabb85 closed this as completed Mar 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants