PDA

View Full Version : Message bus registering components



Grolubao
10 Nov 2010, 12:29 PM
Hi to all,
I've taken a look into Saki's example on a SimpleMessageBus:

http://examples.extjs.eu/?ex=databind

Now, is there a way to just register a component to the bus in order to receive every event from it? I was looking for something like this:



// message bus simulation
Example.Bus = new Ext.util.Observable();
Example.Bus.addEvents('message');

var myPanel = new Ext.Panel({
listeners:{
message: function(){
alert('1');
}
}
});
var myPanel2 = new Ext.Panel({
listeners:{
message: function(){
alert('2');
}
}
});

Example.Bus.registerComponentToListen(myPanel);
Example.Bus.registerComponentToListen(myPanel2);


So whenever I would do Example.Bus.fireEvent('message') I would get both the alerts?

How can I achieve this? I was currently using the relayEvents, but I don't like that approach...

Thanks in advance!