Skip to content

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

Description

@neSpecc

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions