Skip to content

Event Handling #3

Description

@Gozala

As of this writing events handling is done via decoder.flow library. Meaning you can register a listener on the element as follows:

DOMinion.createElement(
  "button",
  [
    DOMinion.on(
      "click",
      Decoder.record({ type: Decoder.String, button: Decoder.Integer })
    )
  ],
  []
)

Then DOMinion library will take care of including AddEventListiner op into generated changelist that can be transferred over to the main thread.

Problems

  • In current implementation RemoveEventListener also serializes event decoder and includes that in a changelist. That seems wasteful. It would make more a lot more sense to not include decoder in a RemoveEventListener op, which can be done either by simply allowing single listener per event type or by registering listeners by id and removing by that id.
  • Same decoders are likely to be used across different elements, but library does no attempt to allow reuse instead same decoders will be serialized and transferred each time. It seem like registering listeners by id and then adding / removing them might be a better way to go. It also would make it easier to remove / add them on the main thread side as there there will be a need to identify which decoder is being added / removed. On the flip side global registry has it's own issue, namely diff(a, b) needs some way to assess if certain event listener existed in tree a and there for can be referred by id or if it needs to be registered first. It also becomes unclear where do we store all event listeners on to make diffing them efficient.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions