Skip to content

mooyah/IEvents

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IEvents

This class provides 2 improvements to the Events mixin:

  1. It provides a mechanism for cancelling events (like with input events)
  2. It fixes an issue with the original class where a broken callback would crash the event loop (will not work for cancellables, as they're execution should be dependable).
  3. Adds the ability to create "latched" events - events that once fired once, will immidietly fire any function that was added afterwards.

How to use

For allowing cancelled events, you need to supply an extra field in your class, named cancellables, which should be an array containing a list on cancellabe event names. What the class will do is to stop the event loop on the first callback that returns false, as well as making fireEvent return false. Look at the demo to see it in action. For "latched" events, add the :latched pseudo selector to the fireEvent call:

#JS
this.fireEvent('load:latched');

About

Improvements to mootool's Events mixin

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%