Created
April 19, 2015 03:58
-
-
Save lelotnk/a2c75cd49d8cc84808ec to your computer and use it in GitHub Desktop.
Definindo um módulo com RequireJs e Module Patten
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
require(['jquery', 'app/mymodule'], function($, MyModule){ | |
MyModule.initialize(); | |
}); |
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
define((function(win, doc, undefined) { | |
'use strict'; | |
function MyModule() | |
{ | |
var $public = {} | |
var $private = {} | |
$public.initialize = function initialize(angle) | |
{ | |
$private.myMethod(); | |
} | |
$private.myMethod = function myMethod() | |
{ | |
console.log('Testing...'); | |
} | |
return $public; | |
} | |
win.MyModule = win.MyModule || {}; | |
win.MyModule = MyModule(); | |
return win.MyModule; | |
})(window, document)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment