]>
git.proxmox.com Git - extjs.git/blob - extjs/packages/core/src/app/bind/BaseBinding.js
2 * This class is the base for `Binding` and `MultiBinding`.
5 Ext
.define('Ext.app.bind.BaseBinding', {
6 extend
: 'Ext.util.Schedulable',
17 * @cfg {Boolean} [single=false]
18 * This option instructs the binding to call its `destroy` method immediately after
19 * delivering the initial value.
23 constructor: function (owner
, callback
, scope
, options
) {
29 me
.callback
= callback
;
33 Ext
.raise('Callback is required');
37 // If given a string callback name, preserve the late binding:
38 me
.lateBound
= Ext
.isString(callback
);
39 if (options
&& options
.deep
) {
46 destroy: function () {
52 owner
.onBindDestroy(me
);
54 me
.scope
= me
.callback
= me
.owner
= null;
57 isReadOnly: function() {
62 getScheduler: function () {
63 var owner
= this.owner
;
64 return owner
&& owner
.getScheduler();
67 getSession: function () {
68 var owner
= this.owner
;
69 return owner
.isSession
? owner
: owner
.getSession();
72 notify: function (value
) {
74 options
= me
.options
|| me
.defaultOptions
,
75 previous
= me
.lastValue
;
77 // We want to deliver if:
78 // 1) We've never been called
79 // 2) We're a deep binding, which means that our object reference may not have changed,
80 // but something under us has changed. For example a link stub or a model field binding
81 // 3) If the value has changed
82 // 4) If the value is an array. It's difficult to tell if the underlying data changed
83 if (!me
.calls
|| me
.deep
|| previous
!== value
|| Ext
.isArray(value
)) {
88 // Interestingly, lateBound-ness may be more efficient since it does
89 // not use the "call" method.
90 me
.scope
[me
.callback
](value
, previous
, me
);
92 me
.callback
.call(me
.scope
, value
, previous
, me
);