Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. /**
  2. * ?????????????????????????????????????????????????????????????????????????
  3. *
  4. * - Using a MYMODULE (revealing module patter) as below
  5. * - Processed with Rollup
  6. *
  7. * `import`ed `cfg()`, `msg()` and `debounce()` are *global*
  8. *
  9. * Q: as `import` may only appear in top-level:
  10. * How can I have these functions scoped to MYMODULE?
  11. *
  12. *
  13. * ????????????????????????????????????????????????????????????????????????? */
  14.  
  15.  
  16. /**
  17. * ES6 `import` dependancy modules
  18. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. */
  20. import cfg from './config.js';
  21. import msg from './msg.js';
  22. import debounce from './debounce.js';
  23.  
  24. /*
  25. * MyModule specific functionality
  26. * ========================================================================= */
  27.  
  28. /**
  29. * MyModule object
  30. * ========================================================================= */
  31. const MYMODULE = (function(win, doc) {
  32.  
  33. /**
  34. * initializes MYMODULE module
  35. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. */
  37. const onInit = function() {
  38. msg('onInit(), called by `MYMODULE.init()`');
  39. };
  40.  
  41.  
  42. /**
  43. * (DEBOUNCED!) Window Resize callback
  44. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. */
  46. const onDebouncedWinResize = debounce(function() {
  47. msg('onDebouncedWinResize()');
  48. }, 250);
  49.  
  50. // .. etc
  51.  
  52. /**
  53. * 'Public' object, containing 'public' aliases of 'private' methods
  54. * @type {Object}
  55. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56. */
  57. const _public = {
  58. init: onInit
  59. };
  60.  
  61. return _public;
  62.  
  63. })(window, document);
  64.  
  65.  
  66. /**
  67. * RUN / Initialize as
  68. * ========================================================================= */
  69. MYMODULE.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement