Last active
August 19, 2016 19:49
-
-
Save diogomachado/f7b0de590d7d08a1d605e8f0967c6f15 to your computer and use it in GitHub Desktop.
Padrão de projeto Javascript (Module Pattern)
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
// Exemplo com encapsulamento de métodos | |
var pedidoMesa1 = (function() { | |
var pedido = {}; | |
pedido.alertar = function(msg){ | |
alert(msg); | |
}; | |
pedido.addItem = function(){ | |
return pedido.alertar('Produto adicionado'); | |
}; | |
pedido.rmItem = function(){ | |
return pedido.alertar('Produto removido'); | |
}; | |
return { | |
addItem : pedido.addItem, | |
rmItem : pedido.rmItem | |
}; | |
})(); | |
pedidoMesa1.addItem(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment