Last active
May 20, 2017 05:47
-
-
Save fraaalk/f228df0e6798399604e57570b2df325a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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; |
This file contains hidden or 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
| 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; |
This file contains hidden or 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
| 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