Skip to content

Instantly share code, notes, and snippets.

@Duder-onomy
Last active August 29, 2015 14:19
Show Gist options
  • Save Duder-onomy/c6ebaef590e876ad546d to your computer and use it in GitHub Desktop.
Save Duder-onomy/c6ebaef590e876ad546d to your computer and use it in GitHub Desktop.
Revealing Module Pattern
define([], function() {

    return {
        play : play,
        stop : stop,
        pause : pause,
        rewind : rewind,
        fastForward : fastForward
    };
    
    function play() {
        ///
    }
    function stop() {
        ///
    }
    function pause() {
        ///
    }
    function rewind() {
        ///
    }
    function fastForward() {
        ///
    }
});

as opposed to:

define([], function() {

    return {
        play : function() {
            ///
        },
        stop : function() {
            ///
        },
        pause : function() {
            ///
        },
        rewind : function() {
            ///
        },
        fastForward : function() {
            ///
        }
    };
    
});

If those methods grow, then you would have to scroll all the way to the bottom of the file to even know that the file had a fastForward method.

With the revealing module, the definition of fastForward,and the implementation are at seperate parts in the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment