Last active
June 24, 2019 13:19
-
-
Save priyankvex2/589e87afb3d328c0f43f8c3934da874e to your computer and use it in GitHub Desktop.
Pokemon controller DI
This file contains 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
function pokemonControllerFactory(pokemonDbLayer){ | |
let pokemonController = {}; | |
function getPokemonProfile(pokemonId){ | |
let pokemonObj = pokemon_db_layer.findById(pokemonId); | |
return { | |
name: pokemonObj ? pokemonObj.name : "", | |
level: pokemonObj ? pokemonObj.level : "" | |
}; | |
} | |
pokemonController.getPokemonProfile = getPokemonProfile; | |
return pokemonController; | |
} | |
module.exports = { | |
pokemonController: pokemonControllerFactory | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment