Created
May 16, 2016 13:29
-
-
Save ryanguill/a16c35a54a1e11ddc32d01e9274fca93 to your computer and use it in GitHub Desktop.
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
/*global _, jQuery */ | |
var APP = APP || {}; | |
//just for testing | |
APP.dependencyOne = true; | |
APP.dependencyTwo = true; | |
APP.player = (function player(dependencyOne, dependencyTwo) { | |
"use strict"; | |
function make (args) { | |
args = args || {}; | |
var state = { | |
team: args.team || "", | |
name: args.name || "", | |
}; | |
function getName () { | |
return state.name; | |
}; | |
function getTeam () { | |
return state.team; | |
}; | |
return { | |
getName: getName, | |
getTeam: getTeam | |
}; | |
}; | |
return { | |
make: make | |
}; | |
}(APP.dependencyOne, APP.dependencyTwo)); //this is for dependencies to the module, not instance args | |
//---------- | |
var p1 = APP.player.make({name: "Player 1", team: "Red Team"}); //instance args go here | |
console.log(p1.getName()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Id probably write these a bit differently in es6, but we've used this pattern for a long time.