PDA

View Full Version : publish subscribe mechanism in EXTJS



meena.chauhan
25 Jul 2012, 8:18 PM
Hi,

I am looking for a publish subscribe mechanism in extjs:

For instance, when I publish my model data in EXTJS model.
My view update its component state by subscribing the model infomation.

Thanks,
Meena Chauhan

evant
25 Jul 2012, 8:34 PM
It's also known as the observable pattern: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.util.Observable

meena.chauhan
25 Jul 2012, 10:20 PM
thanks, for the information.

I tried using Observable in my test application.But I was facing one issue in the publish subscribe.
I have logged one issue in the forum:
http://www.sencha.com/forum/showthread.php?232124-Issue-in-using-Ext.util.Observable

meena.chauhan
26 Jul 2012, 4:12 AM
The publish subscribe using the Observable is not working when we add listener in the different class other than the one which is observable.
please let me know the approach that needs to be used in such a scenario



Ext.define('PlanPM', {

mixins: {
observable: 'Ext.util.Observable'
},

fields:[{name: 'label', type: 'String'}],
constructor : function(config)
{
this.mixins.observable.constructor.call(this, config);
this.addEvents('quit');

},

setLabel: function(label)
{
this._label = label;
this.fireEvent('quit');
},
getLabel: function()
{
return this._label;
}
});





Ext.define('Command', { fields:[{name: 'cmdLabel', type: 'String'}], listeners: { quit: function() { this.execute(); } }, setCmdLabel: function(cmdLabel) { this._cmdLabel = cmdLabel; }, getCmdLabel: function() { return this._cmdLabel; }, execute: function() { alert("Command label "+this._cmdLabel); }});