Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

event-abstract-class

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-abstract-class

ES6 abstract class to extend and allow classes to support native object event binding/triggering.

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
972
increased by24.78%
Maintainers
1
Weekly downloads
 
Created
Source

Travis Build

Event abstract class

ES6 abstract class to extend and allow classes to support native object event binding/triggering.

Example

import EventAbstractClass from 'event-abstract-class'

class Example extends EventAbstractClass {
    constructor () {
        super()
        
        this.value = null
    }
    
    setValue (value) {
        let oldValue = this.value
    
        this.trigger('setValue:pre', {
            newValue: value
        })
        
        this.value = value
        
        this.trigger('setValue:post', {
            newValue: value,
            oldValue: oldValue
        })
    }
}

let example = new Example()

example.on('setValue:post', (args) => {
    console.log('oldValue', args.oldValue)
    console.log('newValue', args.newValue)
})

example.setValue('New value 1!')
example.setValue('New value 2!')

Keywords

FAQs

Package last updated on 22 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc