Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allouis/obstruct
Objects > Constructors
https://github.com/allouis/obstruct
Last synced: 24 days ago
JSON representation
Objects > Constructors
- Host: GitHub
- URL: https://github.com/allouis/obstruct
- Owner: allouis
- License: mit
- Created: 2014-03-20T12:59:10.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-07T14:00:18.000Z (about 10 years ago)
- Last Synced: 2024-09-23T07:38:04.738Z (about 1 month ago)
- Language: JavaScript
- Size: 211 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Obstruct
========Objects > Constructors
Usage
=====Obstruct provides simple inheritance without the use of traditional constructors. Inspired by the Type.new blog post, I wrapped up this functionality in a tiny little lib.
Basic usage:```javascript
var Button = Obstruct.extend({
constructor: function (el) {
this.el = el;
this.addEvents();
},
addEvents: function () {
this.el.addEventListener('click', this.onClick.bind(this));
},
onClick: function (event) {
alert('do suttin');
}
});var EvilButton = Button.extend({
constructor: function () {
console.log('MWHAHAHAHA');
Button.apply(this, arguments); // call `super`
},onClick: function () {
window.location.href = 'http://evil.com'
}});
var mybtn = EvilButton.create(document.querySelector('a'));
```