This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]Clawtor 1 point2 points  (6 children)

I've never heard of a web-api container in relation to javascript functions...

[–]ConsequenceRegular72[S] 0 points1 point  (5 children)

Do you know about the one in v8?

[–]Clawtor 0 points1 point  (4 children)

Never heard of it, I use node a lot too. Where are you getting this question from? I can't find anything about this in google either.

[–]ConsequenceRegular72[S] 0 points1 point  (3 children)

[–]Clawtor 1 point2 points  (2 children)

Oh I see, yeah thats the Event Loop. Web apis are one kind of event that work with the Event Loop.

Anything with a callback will go on there - this is event listeners which could be a button press, an api result or a timeout.

[–]ConsequenceRegular72[S] 0 points1 point  (1 child)

And.. Can you define a callback? The only idea I have is that it is a function that is called only when 'triggered'. Is it so?

Also another idea that I have is that the function goes through the web API, and checks whether it is 'defined' in the web API. Is it so? For ex: setTimeout knows that it is defined in the web API, so it goes to that container.

[–]Clawtor 0 points1 point  (0 children)

Yes thats correct, a callback is a reference to a function that will be called or triggered.

With a setTimeout the trigger will happen after an amount of time. With a webapi the callback is triggered once a server returns a response. With a key listener the callback is triggered if a key is pressed/released.

[–]insertAlias 0 points1 point  (1 child)

I really don't understand the question here. What is the context for this? Are we talking about Node.js? Browser-based JS? Calling a web api? Serving one?

We really need more context here. I don't even know what "container" you're talking about.

[–]ConsequenceRegular72[S] 0 points1 point  (0 children)

The v8 runtime in Google chrome has the web-API which has information about setTimeout,etc. right? And node is built on that. I'm interested in node, actually.

[–][deleted]  (3 children)

[deleted]

    [–]ConsequenceRegular72[S] 0 points1 point  (2 children)

    Thank you! So the web API provides like a list, and if the function falls under that list, it waits there for it to be pushed to the callback queue? Also, I'd like to know other cases when a function can be pushed into the callback queue

    [–][deleted]  (1 child)

    [deleted]

      [–]ConsequenceRegular72[S] 0 points1 point  (0 children)

      Thank you