0.0.4 • Published 10 years ago

obstruct v0.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

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:

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'));
0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

11 years ago

0.0.1

11 years ago