Skip to content

Instantly share code, notes, and snippets.

@guilhermepontes
Last active July 10, 2023 04:54
Show Gist options
  • Select an option

  • Save guilhermepontes/4504159 to your computer and use it in GitHub Desktop.

Select an option

Save guilhermepontes/4504159 to your computer and use it in GitHub Desktop.

Revisions

  1. guilhermepontes revised this gist Sep 12, 2018. 2 changed files with 7 additions and 7 deletions.
    8 changes: 4 additions & 4 deletions module-es2015.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    const Application = ((d) => {
    const privateVariable = 'Private content'

    const _private = {
    const __private = {
    cache: () => {
    this.link = d.querySelector('.link')
    },
    @@ -15,9 +15,9 @@ const Application = ((d) => {

    return {
    init: () => {
    _private.showContent()
    _private.cache()
    _private.bind()
    __private.showContent()
    __private.cache()
    __private.bind()
    }
    }
    })(document)
    6 changes: 3 additions & 3 deletions module.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    var Application = (function(w, d){
    var myPrivateVariable = "My private content";

    var _private = {
    var __private = {
    cache: function(){
    this.link = d.querySelector('.link-item');
    }
    @@ -19,8 +19,8 @@ var Application = (function(w, d){
    init: function(){
    console.log(myPrivateVariable);

    _private.cache();
    _private.bind();
    __private.cache();
    __private.bind();
    }
    };
    })(window, document);
  2. guilhermepontes revised this gist Sep 12, 2018. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions module-es2015.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,9 @@
    const Application = (() => {
    const Application = ((d) => {
    const privateVariable = 'Private content'
    const link = document.querySelector('.link')

    const _private = {
    cache: () => {
    this.link = document.querySelector('.link')
    this.link = d.querySelector('.link')
    },

    bind: () => {
    @@ -21,7 +20,7 @@ const Application = (() => {
    _private.bind()
    }
    }
    })()
    })(document)

    Application.init()
    console.log(privateVariable) //undefined
  3. guilhermepontes revised this gist Sep 12, 2018. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions module-es2015.js
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,14 @@ const Application = (() => {
    const link = document.querySelector('.link')

    const _private = {
    cache: () => this.link = document.querySelector('.link'),
    bind: () => this.link.addEventListener('click', this.showContent, false),
    cache: () => {
    this.link = document.querySelector('.link')
    },

    bind: () => {
    this.link.addEventListener('click', this.showContent, false)
    },

    showContent: () => console.log(privateVariable)
    }

    @@ -17,5 +23,5 @@ const Application = (() => {
    }
    })()

    Application.init() //
    Application.init()
    console.log(privateVariable) //undefined
  4. guilhermepontes revised this gist Oct 13, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion module-es2015.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ const Application = (() => {

    const _private = {
    cache: () => this.link = document.querySelector('.link'),
    bind: () => this.link.addEventListener('click', this.shoshowContentwVariableContent, false),
    bind: () => this.link.addEventListener('click', this.showContent, false),
    showContent: () => console.log(privateVariable)
    }

  5. guilhermepontes revised this gist Oct 13, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module-es2015.js
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@ const Application = (() => {
    const link = document.querySelector('.link')

    const _private = {
    cache: () => (this.link = document.querySelector('.link'))
    bind: () => this.link.addEventListener('click', this.shoshowContentwVariableContent, false),
    cache: () => this.link = document.querySelector('.link'),
    bind: () => this.link.addEventListener('click', this.shoshowContentwVariableContent, false),
    showContent: () => console.log(privateVariable)
    }

  6. guilhermepontes renamed this gist Apr 3, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. guilhermepontes revised this gist Apr 3, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion module-es6.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,6 @@ const Application = (() => {
    showContent: () => console.log(privateVariable)
    }


    return {
    init: () => {
    _private.showContent()
  8. guilhermepontes revised this gist Apr 3, 2017. 1 changed file with 22 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions module-es6.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    const Application = (() => {
    const privateVariable = 'Private content'
    const link = document.querySelector('.link')

    const _private = {
    cache: () => (this.link = document.querySelector('.link'))
    bind: () => this.link.addEventListener('click', this.shoshowContentwVariableContent, false),
    showContent: () => console.log(privateVariable)
    }


    return {
    init: () => {
    _private.showContent()
    _private.cache()
    _private.bind()
    }
    }
    })()

    Application.init() //
    console.log(privateVariable) //undefined
  9. guilhermepontes revised this gist Apr 3, 2017. 1 changed file with 8 additions and 10 deletions.
    18 changes: 8 additions & 10 deletions module.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    var app = (function(w, d){
    var Application = (function(w, d){
    var myPrivateVariable = "My private content";

    var __private = {
    cache : function(){
    var _private = {
    cache: function(){
    this.link = d.querySelector('.link-item');
    }

    bind : function(){
    bind: function(){
    this.link.addEventListener('click', this.handleClick, false);
    },

    @@ -15,17 +15,15 @@ var app = (function(w, d){
    }
    };

    var app = {
    return {
    init: function(){
    console.log(myPrivateVariable);

    __private.cache();
    __private.bind();
    _private.cache();
    _private.bind();
    }
    };

    return app;
    })(window, document);

    app.init(); //init the app
    Application.init(); //init the app
    console.log(myPrivateVariable); // undefined
  10. guilhermepontes revised this gist Sep 8, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions module.js
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@ var app = (function(w, d){
    cache : function(){
    this.link = d.querySelector('.link-item');
    }

    bind : function(){
    this.link.addEventListener('click', this.handleClick, false);
    },
  11. guilhermepontes revised this gist Dec 10, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion module.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    var app = (function(d, w){
    var app = (function(w, d){
    var myPrivateVariable = "My private content";

    var __private = {
  12. guilhermepontes revised this gist Mar 31, 2015. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions module.js
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,30 @@
    var app = (function(){

    var app = (function(d, w){
    var myPrivateVariable = "My private content";

    var __private = {
    bind: function(){

    cache : function(){
    this.link = d.querySelector('.link-item');
    }
    bind : function(){
    this.link.addEventListener('click', this.handleClick, false);
    },
    cache: function() {
    // impl

    handleClick: function(){
    console.log(myPrivateVariable);
    }
    };

    var app = {
    init: function(){
    console.log(myPrivateVariable);

    __private.cache();
    __private.bind();
    },
    blabla: function(){
    // ....
    }
    };

    return app;

    })();
    })(window, document);

    app.init(); // > my private content
    app.myPrivateVariable; // > undefined
    app.init(); //init the app
    console.log(myPrivateVariable); // undefined
  13. guilhermepontes revised this gist Jan 12, 2015. 1 changed file with 16 additions and 13 deletions.
    29 changes: 16 additions & 13 deletions module.js
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,30 @@
    var app;

    app = (function(){
    var app = (function(){

    var myPrivateVariable = "my private content";
    var myPrivateVariable = "My private content";

    var application = {
    init: function(){
    console.log(myPrivateVariable);
    var __private = {
    bind: function(){

    },
    cache: function() {
    // impl
    },
    bind: function() {
    // impl
    }
    };

    var app = {
    init: function(){
    console.log(myPrivateVariable);
    __private.cache();
    __private.bind();
    },
    blabla: function(){
    // ....
    }
    }
    };

    return application;
    return app;

    })();

    app.init(); // > my private content
    app.myPrivateVariable // > undefined
    app.myPrivateVariable; // > undefined
  14. guilhermepontes created this gist Jan 10, 2013.
    27 changes: 27 additions & 0 deletions module.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    var app;

    app = (function(){

    var myPrivateVariable = "my private content";

    var application = {
    init: function(){
    console.log(myPrivateVariable);
    },
    cache: function() {
    // impl
    },
    bind: function() {
    // impl
    },
    blabla: function(){
    // ....
    }
    }

    return application;

    })();

    app.init(); // > my private content
    app.myPrivateVariable // > undefined