Skip to content
Snippets Groups Projects
Commit 46a6995e authored by Neuber, Eugen Ramon's avatar Neuber, Eugen Ramon :speech_balloon:
Browse files

Change Provider.id() to Provider.id

parent 3fdbad9e
No related branches found
No related tags found
1 merge request!28Observer test
Pipeline #15917 passed with warnings
...@@ -8,14 +8,14 @@ export class Provider extends HTMLElement { ...@@ -8,14 +8,14 @@ export class Provider extends HTMLElement {
} }
connectedCallback() { connectedCallback() {
console.log('Provider(' + this.id() + ') connectedCallback()'); console.log('Provider(' + this.id + ') connectedCallback()');
const that = this; const that = this;
this.addEventListener('subscribe', function (e) { this.addEventListener('subscribe', function (e) {
const name = e.detail.name; const name = e.detail.name;
if (that[name] || that.root) { if (that[name] || that.root) {
console.log('Provider(' + that.id() + ') eventListener("subscribe",..) name "' + name + '" found.'); console.log('Provider(' + that.id + ') eventListener("subscribe",..) name "' + name + '" found.');
that.callbackStore.push({name: name, callback: e.detail.callback, sender: e.detail.sender}); that.callbackStore.push({name: name, callback: e.detail.callback, sender: e.detail.sender});
e.detail.callback(that[name]); e.detail.callback(that[name]);
...@@ -27,12 +27,12 @@ export class Provider extends HTMLElement { ...@@ -27,12 +27,12 @@ export class Provider extends HTMLElement {
const name = e.detail.name; const name = e.detail.name;
const sender = e.detail.sender; const sender = e.detail.sender;
if (that[name] || that.root) { if (that[name] || that.root) {
console.log('Provider(' + that.id() + ') eventListener("unsubscribe",..) name "' + name + '" found.'); console.log('Provider(' + that.id + ') eventListener("unsubscribe",..) name "' + name + '" found.');
that.callbackStore.forEach(item => { that.callbackStore.forEach(item => {
if (item.sender === sender && item.name === name) { if (item.sender === sender && item.name === name) {
const index = that.callbackStore.indexOf(item); const index = that.callbackStore.indexOf(item);
that.callbackStore.splice(index, 1); that.callbackStore.splice(index, 1);
console.log('Provider(' + that.id() + ') eventListener for name "' + name + '" removed.'); console.log('Provider(' + that.id + ') eventListener for name "' + name + '" removed.');
} }
}); });
...@@ -46,7 +46,7 @@ export class Provider extends HTMLElement { ...@@ -46,7 +46,7 @@ export class Provider extends HTMLElement {
const value = e.detail.value; const value = e.detail.value;
if (that[name] || that.root) { if (that[name] || that.root) {
console.log('Provider(' + that.id() + ') eventListener("set-property",..) name "' + name + '" found.'); console.log('Provider(' + that.id + ') eventListener("set-property",..) name "' + name + '" found.');
that[name] = value; that[name] = value;
that.callbackStore.forEach(item => { that.callbackStore.forEach(item => {
...@@ -70,7 +70,7 @@ export class Provider extends HTMLElement { ...@@ -70,7 +70,7 @@ export class Provider extends HTMLElement {
const name = mutation.attributeName; const name = mutation.attributeName;
const value = that.getAttribute(name); const value = that.getAttribute(name);
if (that[name] !== value) { if (that[name] !== value) {
console.log('Provider (' + that.id() + ') observed attribute "' + name + '" changed'); console.log('Provider (' + that.id + ') observed attribute "' + name + '" changed');
that[name] = value; that[name] = value;
that.callbackStore.forEach(item => { that.callbackStore.forEach(item => {
if (item.name === name) { if (item.name === name) {
...@@ -97,12 +97,12 @@ export class Provider extends HTMLElement { ...@@ -97,12 +97,12 @@ export class Provider extends HTMLElement {
} }
this[attrs[i].name] = attrs[i].value; this[attrs[i].name] = attrs[i].value;
console.log('Provider (' + that.id() + ') found attribute "' + attrs[i].name + '" = "' + attrs[i].value + '"'); console.log('Provider (' + that.id + ') found attribute "' + attrs[i].name + '" = "' + attrs[i].value + '"');
} }
} }
} }
id() { get id() {
return this.getAttribute('id'); return this.getAttribute('id');
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment