Page 2 of 2

Re: Disconnect class ?

Posted: 18 August 2015, 12:28
by Coin-coin le Canapin
I've done this and it seems to work as expected :

Code: Select all

        connectClass: function(className, event, handler)
        {
           var list= dojo.query("."+className);
            this.connections[className] = [];
            for(var i=0;i<list.length;i++) {
                var element = list[i];
                this.connections[className].push({ 
                    className: className, 
                    element: element, 
                    event: event,
                    handle: dojo.connect(element, event, this, handler)
                });
           }           
        }

Code: Select all

        disconnectClass: function(className) {
            if(className in this.connections) {
                for(var i=0;i<this.connections[className].length;i++) {
                    connection = this.connections[className][i];
                    dojo.disconnect(connection.handle);
                }
                delete this.connections[className];
            }
        }

Re: Disconnect class ?

Posted: 18 August 2015, 13:54
by pikiou
You're modifying this.connectClass() and this.connections, which are part of the library of BGA.
So better rename them if you want your game to survive future BGA updates which would make use of this.connect, this.disconnect or this.disconnectAll.

Re: Disconnect class ?

Posted: 18 August 2015, 17:17
by Coin-coin le Canapin
Right, I was asking myself the question instead of asking here :D

Re: Disconnect class ?

Posted: 18 August 2015, 22:11
by Rudolf
also better store connection with node? what do you think Pikiou?