Last active
          May 7, 2016 22:25 
        
      - 
      
 - 
        
Save raggi/2cf83cb9a2048eef0a0f56582dc8f146 to your computer and use it in GitHub Desktop.  
    Modern JS event handling mixin
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const Handler = Base => class extends Base { | |
| handleEvent (evt) { | |
| return this[`on${evt.type.replace(/^./, c => c.toUpperCase())}`](evt) | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Usage example: