Skip to content

Commit

Permalink
Add getters and setters for component id to sync up internal emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixHenninger committed Sep 20, 2024
1 parent f081e06 commit 231b38a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/library/src/base/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type Metadata = {
}

export class Component {
id?: string
#id?: string
options: any
data: any
static metadata: Metadata
Expand All @@ -116,7 +116,7 @@ export class Component {
constructor(options: Partial<ComponentOptions> = {}) {
const { id, debug } = options

this.id = id
this.#id = id
this.status = Status.initialized
this.data = options.data ?? {}

Expand Down Expand Up @@ -164,6 +164,17 @@ export class Component {
}
}

get id(): string | undefined {
return this.#id
}

set id(v: string) {
this.#id = v

// Pass through ID to emitter
this.#emitter.id = this.id
}

async prepare(directCall = true) {
if (this.options.tardy && !directCall) {
this.log('Skipping automated preparation')
Expand Down

1 comment on commit 231b38a

@nnakagaki
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Please sign in to comment.