Skip to content

Instantly share code, notes, and snippets.

@fraaalk
Last active May 20, 2017 05:47
Show Gist options
  • Select an option

  • Save fraaalk/f228df0e6798399604e57570b2df325a to your computer and use it in GitHub Desktop.

Select an option

Save fraaalk/f228df0e6798399604e57570b2df325a to your computer and use it in GitHub Desktop.
const moduleFactory = function moduleFactoryFn(moduleName = '') {
const module = function moduleConstructor(element = null, options = {}) {
// call init function of module
this.init(element, options);
}
module.prototype.baseFunctionality1() {};
module.prototype.baseFunctionality2() {};
return module;
}
module.exports = moduleFactory;
const Modal = require('base-component.js')('modal');
Modal.prototype.init = function init() {
// do stuff for modal init
};
// open method
Modal.prototype.open = function open(){}
Modal.prototype.render = function render(){}
Modal.prototype.close = function close(){}
Modal.prototype.destroy = function destroy(){}
module.exports = Modal;
const Modal = require('modal.js');
const Movie = require('base-component.js')('movie');
Movie.prototype.init = function init() {
// do other stuff and display a modal
this.modal = new Modal();
this.displayModal();
}
Movie.prototype.displayModal() {
this.modal.open();
}
module.exports = Movie;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment