Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * ?????????????????????????????????????????????????????????????????????????
- *
- * - Using a MYMODULE (revealing module patter) as below
- * - Processed with Rollup
- *
- * `import`ed `cfg()`, `msg()` and `debounce()` are *global*
- *
- * Q: as `import` may only appear in top-level:
- * How can I have these functions scoped to MYMODULE?
- *
- *
- * ????????????????????????????????????????????????????????????????????????? */
- /**
- * ES6 `import` dependancy modules
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
- import cfg from './config.js';
- import msg from './msg.js';
- import debounce from './debounce.js';
- /*
- * MyModule specific functionality
- * ========================================================================= */
- /**
- * MyModule object
- * ========================================================================= */
- const MYMODULE = (function(win, doc) {
- /**
- * initializes MYMODULE module
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
- const onInit = function() {
- msg('onInit(), called by `MYMODULE.init()`');
- };
- /**
- * (DEBOUNCED!) Window Resize callback
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
- const onDebouncedWinResize = debounce(function() {
- msg('onDebouncedWinResize()');
- }, 250);
- // .. etc
- /**
- * 'Public' object, containing 'public' aliases of 'private' methods
- * @type {Object}
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
- const _public = {
- init: onInit
- };
- return _public;
- })(window, document);
- /**
- * RUN / Initialize as
- * ========================================================================= */
- MYMODULE.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement