0

I was learning how zone.js monkey-patches browseraAPI(basically async tasks), and fork hooks to notify when an activity starts and ends.

setTimeOut is browserAPI not a javascript thing, so Zone can patch it but how about onclick, onkeydown.............. events? As per my understanding , zone patches only browser APIs then how change detection is getting triggered when i do button click or a keydown or any user interaction?

Or my nderstanding is wrong. Zone can patch any event?

kboul
  • 13,836
  • 5
  • 42
  • 53
Subhadeep
  • 257
  • 5
  • 13
  • The DOM (and it's associated event model) is not part of JavaScript (nor is it *unique* to JavaScript). And generally speaking, in JS-land you can overwrite almost *anything*. – Jared Smith Jun 21 '18 at 20:15
  • One more confusion i have. I know resize,scroll and animation are browser events but how will you catigorize onclick,keydown,........user event or what? And also , this onclick , keydown.. these are browser API or Javascript API? And also as i know setTimeout is browser API, but we write it in javascript. How things are working behind the scene. So how javascript interacting with the API exposed by browser?What is the wrapper Object here? – Subhadeep Jun 22 '18 at 20:03
  • Check out [my answer here](https://stackoverflow.com/a/39946046/3757232), that will probably clear up a lot of your confusion. Short answer is: it doesn't matter, and unless you are looking to author your own web browser you probably needn't concern yourself with the difference. – Jared Smith Jun 25 '18 at 13:07

1 Answers1

0

onclick,onkeydown is also patched as addEventListener. So everything handled inside eventHandler will also auto trigger Change Detection.

jiali passion
  • 1,691
  • 1
  • 14
  • 19
  • One more confusion i have. I know resize,scroll and animation are browser events but how will you catigorize onclick,keydown,........user event or what? And also , this onclick , keydown.. these are browser API or Javascript API? And also as i know setTimeout is browser API, but we write it in javascript. How things are working behind the scene. So how javascript interacting with the API exposed by browser?What is the wrapper Object here? – Subhadeep Jun 22 '18 at 20:04
  • you can find more information here https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onclick – jiali passion Jun 23 '18 at 02:53