Skip to content

Support for events? #16

@rolfen

Description

@rolfen

I would like to use your library, yet I do not see any code dealing with events.

I could register events on the container, however I believe that it is preferable to have the option of registering events on all elements.

I am sure there are different strategies to deal with events.

Maybe the simplest and most flexible option is to have an additional optional parameter on the hyperscript function (el()), it would be a function, and this function gets called every time the HTML element corresponding to that vnode gets modified, or created.

Basically like "lifecycle events" for HTML elements which are managed by SVD.

So for example:

el('a', {'href':'#something'}, null, function(element, lifecycleEvent){
   if(lifecycleEvent == 'created') {
      // the HTML element for this vdom node was just created, add event listeners
      element.addEventListener('click', function(){
          // attach an event listener
      });
   }
});

We can then build on this functionality to do more complicated things if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions