Rework based on Mads notes

This commit is contained in:
Warren Buckley
2023-02-14 12:08:30 +00:00
parent c4fa350b04
commit c00b77791e
3 changed files with 41 additions and 20 deletions

View File

@@ -31,6 +31,9 @@ export class UmbContextProvider<HostType extends EventTarget = EventTarget> {
public hostConnected() {
this.host.addEventListener(umbContextRequestEventType, this._handleContextRequest);
this.host.dispatchEvent(new UmbContextProvideEventImplementation(this._contextAlias));
// Listen to our debug event 'umb:debug-contexts'
this.host.addEventListener('umb:debug-contexts', this._handleDebugContextRequest);
}
/**
@@ -54,6 +57,17 @@ export class UmbContextProvider<HostType extends EventTarget = EventTarget> {
event.callback(this.#instance);
};
private _handleDebugContextRequest = (event: Event) => {
console.log('Context Alias:', this._contextAlias);
console.log('Context Instance:', this.#instance);
// Do I update an array on the event which
// The Debug element can then render in UI?!
console.log('Event:', event);
};
destroy(): void {
// I want to make sure to call this, but for now it was too overwhelming to require the destroy method on context instances.