Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 01 Non blocking/src/js/apiIceAndFire.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const getRequest = (config) => {
};

const sendGetRequest = (req, url) => {
req.open('get', url, true);
req.open('get', url, false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that this works with true.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is realized by the function added in main.js. I think it executes the two calls concurrently.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse me, i thinks with the function and the nested calls its execute secuencially.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right but then the exercise will be very easy ;)

req.send();
};

Expand Down
17 changes: 15 additions & 2 deletions 01 Non blocking/src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,33 @@ document.onreadystatechange = () => {
err: handleError,
callback: handleHousesRequestSucces(apiMapper, printer)
};
service.getHousesByName(houseInput.value, housesRequestConfig);

console.log('2');
const charactersRequestConfig = {
err: handleError,
callback: handleCharactersRequestSuccess(apiMapper, printer)
};
service.getCharactersByName(characterInput.value, charactersRequestConfig);

asyncservice ("GETHOUSE", function (){
service.getHousesByName(houseInput.value, housesRequestConfig);
asyncservice("GETPERSONAJE",function (){
service.getCharactersByName(characterInput.value, charactersRequestConfig);
})
});

console.log('3');
} else {
alert('Introduce a values')
}
});
};

function asyncservice (tipo, callback)
{
console.log('Ejecución proceso =', tipo);
callback ();
}

function handleError() {
console.log(JSON.parse(this.responseText));
};
Expand Down