For the below code,
var fs = require('fs');
fs.watch('target.txt', function(event, fileName){
console.log('Event: ' + event + ', for file: ' + fileName);
});
Console.log('Now watching target.txt');
As per the below architecture,
1) fs.watch()
will invoke libuv
. libuv
will launch a thread to track change
event on target.txt
. The result from libuv
will go to v8
and again through NodeJS Bindings
in the form of callback with a buffer having data.
2) libuv
adds change
event in Event queue. As the event loop picks the change
event, corresponding call back is executed in v8
run time.
Is my understanding correct?