Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(block-tool-adapter): optimise model listeners count #72

Open
neSpecc opened this issue Mar 22, 2024 · 0 comments
Open

(block-tool-adapter): optimise model listeners count #72

neSpecc opened this issue Mar 22, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@neSpecc
Copy link
Contributor

neSpecc commented Mar 22, 2024

Right now each call of the attachInput() lead adding the new event listener to the model. Then, handler will filter-our other inputs.

  public attachInput(key: DataKey, input: HTMLElement): void {
    
    // ... 
    
    this.#model.addEventListener(EventType.Changed, (event: ModelEvents) => this.#handleModelUpdate(event, input, key, caretAdapter));
  }

We know that Tool can have many inputs (e.g. Table or Nested List). So it would be better to add a single event listener in the adapter's constructor. And then, find and handle events related to attached inputs.

Probably, we will need to store inputs in a private property.

@neSpecc neSpecc added the good first issue Good for newcomers label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant