Skip to content

Commit

Permalink
refactor js
Browse files Browse the repository at this point in the history
  • Loading branch information
kikiklang committed Feb 26, 2022
1 parent 77778cb commit 6ee008b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/openweather/openweather.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const loaderContainer = document.querySelector('pp-openweather-loader-container'
* @returns {void} Nothing
*/
export async function startOpenWeatherModule() {
const [dom, data] = await Promise.all([catchOpenWeatherDomElements(), getOpenWeatherData()])
const dom = catchOpenWeatherDomElements()
const data = await getOpenWeatherData()

fillOpenWeatherDomElements(data, dom)
openweatherInner.addEventListener('click', toggleOpenWeatherDisplay)
loaderContainer.style.display = 'none'
Expand Down Expand Up @@ -38,10 +40,9 @@ async function getOpenWeatherData() {

/**
* GET DOM elements that will later be filled with data
* @async
* @returns {Promise} Promise object that resolved with DOM elements contained in an object
* @returns {Object} DOM elements contained in an object
*/
async function catchOpenWeatherDomElements() {
function catchOpenWeatherDomElements() {
return {
container: document.querySelector('pp-openweather'),
temperature: document.querySelector('.temp-value'),
Expand Down
8 changes: 4 additions & 4 deletions src/stormglass/stormglass.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const stormglassLoaderContainer = document.querySelector('pp-stormglass-loader-c
* @returns {void} Nothing
*/
export async function startStormglassModule() {
const [dom, data] = await Promise.all([catchStormglassDomElements(), getStormglassData()])
const dom = catchStormglassDomElements()
const data = await getStormglassData()

fillStormglassDomElements(dom, data)
stormglassLoaderContainer.style.display = 'none'
Expand Down Expand Up @@ -41,10 +42,9 @@ async function getStormglassData() {

/**
* Get DOM elements that will later be filled with data
* @async
* @returns {Promise} Promise object that resolved with DOM elements contained in an object
* @returns {Object} DOM elements contained in an object
*/
async function catchStormglassDomElements() {
function catchStormglassDomElements() {
return {
stormglassContainer: document.querySelector('pp-stormglass'),
spotName: document.querySelector('.header-spot'),
Expand Down

0 comments on commit 6ee008b

Please sign in to comment.