Edgar
Edgar

Reputation: 1120

ExtJS bind to singleton object

I am trying to bind to value in defined class, to react on it change. But no reaction happens. I extended object from data.Model, and trying to bind via links, but something doing wrong.

class with parameter:

Ext.define('Platform.core.OssStatusAdapter', {
extend : 'Ext.data.Model',
alternateClassName : [ 'OssStatusAdapter' ],
singleton : true,

fields : [ {
    name : 'ossConected',
    type : 'boolean',
    defaultValue : false
} ]

});

Code in some class where value is changed:

        OssStatusAdapter.set('ossConected',event.connected);

code where expect reaction to binding:

Ext.define('Plugin.scheduler.package.config.PackageConfigurationViewModel', {
    extend : 'Ext.app.ViewModel',
...
    links: {
        ossAdapter: {
            type: 'Platform.core.OssStatusAdapter',
            create: true
        }
    },
...
    formulas : {
        canDeploy : {
            bind : {

                isOssUp : '{ossAdapter.ossConected}'
            },
            get : function(data) {
                return data.isOssUp;
            }
        }
}

but in formula value is not changing. What I missed?

Upvotes: 0

Views: 857

Answers (1)

rixo
rixo

Reputation: 25041

Try to define your formula this way:

formulas: {
    canDeploy: function(get) {
        var connected = get('ossAdapter.ossConected');
        // see if this moves when you change the record
        console.log('connected', connected);
        return connected;
    }
}

Upvotes: 1

Related Questions