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
function startProgram() { | |
if (!window.indexedDB) { | |
throw new Error("Browser doesn't support indexedDB"); | |
} | |
initDatabase(); | |
setListeners(); | |
printEmployeeList(); | |
} |
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
if (isWildPokemon === true) { | |
usePokeball(); | |
} | |
if (isPokemon === true && isSaved === false) { | |
save(pokemon); | |
} |
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
if (isWildPokemon) { | |
usePokeball(); | |
} | |
if (isPokemon && !isSaved) { | |
save(pokemon); | |
} |
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
function isWildPokemon(pokemon) { | |
if (pokemon.isWild) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function isSaved(pokemonId) { | |
if (this.savedPokemon.some(({ id }) => id === pokemonId)) { |
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
function isWildPokemon(pokemon) { | |
return pokemon.isWild; | |
} | |
function isSaved(pokemonId) { | |
return this.savedPokemon.some(({ id }) => id === pokemonId); | |
} |
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
function attack(pokemon) { | |
if (pokemon.type === 'water') { | |
useWaterAttack(); | |
} else if (pokemon.type === 'fire') { | |
useFireAttack(); | |
} else if (pokemon.type === 'ice') { | |
useIceAttack(); | |
} else if (pokemon.type === 'electric') { | |
useElectricAttack(); | |
} else { |
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
Show hidden characters
{ | |
"compilerOptions": { | |
... | |
"baseUrl": "src", | |
"paths": { | |
"@models/*": ["models/*"], | |
"@shared": ["shared/*"] | |
} | |
}, | |
} |
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
getTrainer().subscribe(trainer => | |
getStarterPokemon(trainer).subscribe(pokemon => | |
// Do stuff with pokemon | |
) | |
); |
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
getTrainer() | |
.pipe( | |
switchMap(trainer => getStarterPokemon(trainer)) | |
) | |
.subscribe(pokemon => { | |
// Do stuff with pokemon | |
}); |
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
pokemonSubscription = pokemon$.subscribe(pokemon => { | |
// Do something with pokemon | |
}); | |
pokemonSubscription.unsubscribe(); |