Skip to content

Instantly share code, notes, and snippets.

@erikakers
Last active August 29, 2015 14:01
Show Gist options
  • Save erikakers/67e41ee4e64b822451b5 to your computer and use it in GitHub Desktop.
Save erikakers/67e41ee4e64b822451b5 to your computer and use it in GitHub Desktop.
Javascript: Loose Augmentation Module Pattern with LoDash Extends Object using the constructor method. Used for data intensive functions.
App.Features.sampleFeature = (function(sample) {
function Feature(element) {
this.$el = element;
};
Feature.Constants = {
};
_.extend(Feature.prototype, App.Class, {
init: function() {
this.setElems(this.$el);
this.options = _.extend(Feature.Constants);
this.bindEvents();
},
setElems: function(element) {
this.els = {
header: element.find('.class')
};
},
bindEvents: function() {
// this.els.element.on('event'. _.bind(this.function, this));
// $.subscribe('test-event', _.bind(this.pubsubEvent, this));
}
});
sample.init = function(element) {
var feature = new Feature(element);
feature.init();
return feature;
};
return sample;
}(App.Features.sampleFeature || {}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment