Last active
August 29, 2015 14:01
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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