Skip to content

New Pronto events interface #234

@arvgta

Description

@arvgta

In a pure JS environment without jQuery, addEventListener() is used to register events instead of e.g. the old jQuery on().
One disadvantage of addEventListener() is that it does not deduplicate registration of pairs of event and event handler and therefore these can pile up in an unwanted way especially in an Ajax environment.

So, in order to at least deduplicate their registration, we've introduced a new convenience function for the user:

function _won(a, b, c = false) { if(c === false) c = {once: true}; setTimeout( () => window.addEventListener(a, b, c) ); };

...which can be called e.g. like this:

<script>_won('pronto.render', function(event) {
  console.log( event );
  });
</script>

For extensive documentation, please see the Events page on 4nf.org.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions