feat: meta.emit
This commit is contained in:
parent
c1f18949e5
commit
c240ee6337
|
@ -23,6 +23,12 @@ export function PropertyMixin(key, meta = {}) {
|
|||
meta.transformProperty = (key) => `${key}_PRIVATE_PROPERTY`;
|
||||
}
|
||||
|
||||
meta.emit = meta.emit || function(...args) {
|
||||
if (this.emit) {
|
||||
this.emit(...args);
|
||||
}
|
||||
}
|
||||
|
||||
meta.eq = meta.eq || function (l, r) {
|
||||
return l === r;
|
||||
}
|
||||
|
@ -65,8 +71,8 @@ export function PropertyMixin(key, meta = {}) {
|
|||
set: function (value) {
|
||||
const old = meta.get.call(this);
|
||||
meta.set.call(this, value);
|
||||
if (this.emit && !meta.eq.call(this, old, value)) {
|
||||
this.emit(`${key}Changed`, old, value)
|
||||
if (meta.track && meta.emit && !meta.eq.call(this, old, value)) {
|
||||
meta.emit.call(this, `${key}Changed`, old, value);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user