event-abstract-class

event-abstract-class

Showing:

Popularity

Downloads/wk

17

GitHub Stars

0

Maintenance

Last Commit

6yrs ago

Contributors

1

Package

Dependencies

0

Size (min+gzip)

0.9KB

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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!')

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial