{"id":66,"date":"2019-09-21T21:40:45","date_gmt":"2019-09-21T21:40:45","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/nodejs\/?p=66"},"modified":"2020-08-06T09:55:47","modified_gmt":"2020-08-06T09:55:47","slug":"07-node-js-event-loops","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/","title":{"rendered":"Node.js &#8211; Event Loops"},"content":{"rendered":"<p>In the previous lesson, we talked about <a href=\"https:\/\/www.kindsonthegenius.com\/nodejs\/node-js-introduction-to-callback\/\">Callbacks<\/a>. Now, we would learn of something a bit similar. That is Event Loops.<\/p>\n<p>Event loops and callbacks are features used by Node.js to support concurrency. This is because Node.js is single-threaded application.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Events in Node.js<\/strong><\/p>\n<p>Node.js is an event-driven program. This means that the main program loops listens for events to occurs. Then when an event occurs, a callback is triggered. Already, you know that callbacks are functions that are called when an event is detects.<\/p>\n<p>This is what is also called the <strong>observer pattern.<\/strong><\/p>\n<p>This means that a loop (event loop) is maintained which keeps listening(observing) for events. This is exactly what happens in <strong>event-driven<\/strong> programs. This make sense too because, throughout the life of a program, events keep occurring. Hence the name event loop. This is illustrated in the figure 1 below:<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_67\" aria-describedby=\"caption-attachment-67\" style=\"width: 640px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loop.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-67\" src=\"https:\/\/kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loop-1024x476.jpg\" alt=\"Event Loop in Node.js\" width=\"640\" height=\"298\" srcset=\"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loop-1024x476.jpg 1024w, https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loop-300x139.jpg 300w, https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loop-768x357.jpg 768w, https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loop.jpg 1039w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-67\" class=\"wp-caption-text\">Figure 1: Event Loop in Node.js<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p><strong>Events vs Callbacks<\/strong><\/p>\n<p>As you know, a callback fires when an asynchronous function returns data.For instance, the readFile() function is an async functions that returns the content of a file. In this case it is callback.The code is given below<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">var<\/span> fs <span style=\"color: #333333;\">=<\/span> require(<span style=\"background-color: #fff0f0;\">\"fs\"<\/span>)\r\n<span style=\"color: #008800; font-weight: bold;\">var<\/span> path <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"D:\/nodefiles\/testinput.txt\"<\/span>;\r\nfs.readFile(path, <span style=\"color: #008800; font-weight: bold;\">function<\/span>(err, data){ \r\n   <span style=\"color: #888888;\">\/\/perform some action<\/span>\r\n});\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>However, in the case of event, the function (observer) listens for events to occur. Then when an even occurs, then the event listener executes. In Node.js, there are many in-built events. You can find them in the events module and EventEmitter class. Both are used to bind events to event-listeners.<\/p>\n<p>An example of event is file open. So we can have a listener that listens to file-open event. And when it detects it, it fires an event listener.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">var<\/span> fs <span style=\"color: #333333;\">=<\/span> require(<span style=\"background-color: #fff0f0;\">'fs'<\/span>);\r\n<span style=\"color: #008800; font-weight: bold;\">var<\/span> path <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">'D:\/nodefiles\/testinput.txt'<\/span>;\r\n<span style=\"color: #008800; font-weight: bold;\">var<\/span> rs <span style=\"color: #333333;\">=<\/span> fs.createReadStream(path);\r\nrs.on(<span style=\"background-color: #fff0f0;\">'open'<\/span>, <span style=\"color: #008800; font-weight: bold;\">function<\/span> () {\r\n  console.log(<span style=\"background-color: #fff0f0;\">'A file have been opened'<\/span>);\r\n});\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Let&#8217;s now write another program that uses a complete event loop. The program is as given below;<\/p>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"margin: 0; line-height: 125%;\"> 1\r\n 2\r\n 3\r\n 4\r\n 5\r\n 6\r\n 7\r\n 8\r\n 9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26<\/pre>\n<\/td>\n<td>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\">\/\/ Import the events module<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">var<\/span> events <span style=\"color: #333333;\">=<\/span> require(<span style=\"background-color: #fff0f0;\">\"events\"<\/span>);\r\n\r\n<span style=\"color: #888888;\">\/\/Create an eventEmitter variable<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">var<\/span> eventEmitter <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> events.EventEmitter();\r\n\r\n<span style=\"color: #888888;\">\/\/ Create and eventHandler function<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">var<\/span> connectHandler <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">function<\/span> connected() {\r\n    console.log(<span style=\"background-color: #fff0f0;\">\"connection succeeded\"<\/span>);\r\n\r\n    <span style=\"color: #888888;\">\/\/Then fire the data_recieved event as follows<\/span>\r\n    eventEmitter.emit(<span style=\"background-color: #fff0f0;\">\"data_received\"<\/span>);\r\n}\r\n\r\n<span style=\"color: #888888;\">\/\/ Bind the connection even with the connectHandler<\/span>\r\neventEmitter.on(<span style=\"background-color: #fff0f0;\">\"connection\"<\/span>, connectHandler);\r\n\r\n<span style=\"color: #888888;\">\/\/ Bind the data_recieved event with a function<\/span>\r\neventEmitter.on(<span style=\"background-color: #fff0f0;\">\"data_received\"<\/span>, <span style=\"color: #008800; font-weight: bold;\">function<\/span>(){\r\n    console.log(<span style=\"background-color: #fff0f0;\">\"Data was received!\"<\/span>);\r\n});\r\n\r\n<span style=\"color: #888888;\">\/\/ Now let's fire the connection event<\/span>\r\neventEmitter.emit(<span style=\"background-color: #fff0f0;\">\"connection\"<\/span>);\r\n\r\nconsole.log(<span style=\"background-color: #fff0f0;\">\"End of Program\"<\/span>);\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Listing 1 &#8211; Event Loop<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Explaining Listing 1<\/strong><\/p>\n<p>Let&#8217;s try to understand what is happening in Listing 1. I have added line numbers to simplify the explanation.<\/p>\n<p>In line 24, we fired the connection event. This calls the connectHandler in lines 7 to 13.<\/p>\n<p>The connectHandler fires data_recieved event. This calls the data_recieved handler function in line 19. This is an anonymous function.<\/p>\n<p>Also note that in lines 16 and 19, we how how the events are bound to the corresponding eventListeners (handlers).<\/p>\n<p>&nbsp;<\/p>\n<p>I save this file as events2.js. The output is shown below:<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Emitter-Output-in-Node.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-73 aligncenter\" src=\"https:\/\/kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Emitter-Output-in-Node.jpg\" alt=\"Event Emitter Output in Node\" width=\"706\" height=\"370\" srcset=\"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Emitter-Output-in-Node.jpg 706w, https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Emitter-Output-in-Node-300x157.jpg 300w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>I would recommend you watch the video to get a clearer understanding.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous lesson, we talked about Callbacks. Now, we would learn of something a bit similar. That is Event Loops. Event loops and callbacks &hellip; <\/p>\n","protected":false},"author":1,"featured_media":68,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1],"tags":[9],"class_list":["post-66","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-node-js-tutorials","category-uncategorized","tag-event-loops"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Node.js - Event Loops - Node.js Tutorials<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Node.js - Event Loops - Node.js Tutorials\" \/>\n<meta property=\"og:description\" content=\"In the previous lesson, we talked about Callbacks. Now, we would learn of something a bit similar. That is Event Loops. Event loops and callbacks &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/\" \/>\n<meta property=\"og:site_name\" content=\"Node.js Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-21T21:40:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-06T09:55:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loops-in-Node.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"879\" \/>\n\t<meta property=\"og:image:height\" content=\"334\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"headline\":\"Node.js &#8211; Event Loops\",\"datePublished\":\"2019-09-21T21:40:45+00:00\",\"dateModified\":\"2020-08-06T09:55:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/\"},\"wordCount\":415,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2019\\\/09\\\/Event-Loops-in-Node.jpg\",\"keywords\":[\"Event Loops\"],\"articleSection\":[\"Node.js Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/\",\"name\":\"Node.js - Event Loops - Node.js Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2019\\\/09\\\/Event-Loops-in-Node.jpg\",\"datePublished\":\"2019-09-21T21:40:45+00:00\",\"dateModified\":\"2020-08-06T09:55:47+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2019\\\/09\\\/Event-Loops-in-Node.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2019\\\/09\\\/Event-Loops-in-Node.jpg\",\"width\":879,\"height\":334,\"caption\":\"Event Loops in Node\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/07-node-js-event-loops\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Node.js &#8211; Event Loops\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/\",\"name\":\"Node.js Tutorials\",\"description\":\"Best Node.js Tutorials\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/nodejs\\\/author\\\/kindsonthegenius-3\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Node.js - Event Loops - Node.js Tutorials","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/","og_locale":"en_US","og_type":"article","og_title":"Node.js - Event Loops - Node.js Tutorials","og_description":"In the previous lesson, we talked about Callbacks. Now, we would learn of something a bit similar. That is Event Loops. Event loops and callbacks &hellip;","og_url":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/","og_site_name":"Node.js Tutorials","article_published_time":"2019-09-21T21:40:45+00:00","article_modified_time":"2020-08-06T09:55:47+00:00","og_image":[{"width":879,"height":334,"url":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loops-in-Node.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"headline":"Node.js &#8211; Event Loops","datePublished":"2019-09-21T21:40:45+00:00","dateModified":"2020-08-06T09:55:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/"},"wordCount":415,"commentCount":1,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loops-in-Node.jpg","keywords":["Event Loops"],"articleSection":["Node.js Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/","url":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/","name":"Node.js - Event Loops - Node.js Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loops-in-Node.jpg","datePublished":"2019-09-21T21:40:45+00:00","dateModified":"2020-08-06T09:55:47+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loops-in-Node.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-content\/uploads\/sites\/5\/2019\/09\/Event-Loops-in-Node.jpg","width":879,"height":334,"caption":"Event Loops in Node"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/07-node-js-event-loops\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/nodejs\/"},{"@type":"ListItem","position":2,"name":"Node.js &#8211; Event Loops"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#website","url":"https:\/\/www.kindsonthegenius.com\/nodejs\/","name":"Node.js Tutorials","description":"Best Node.js Tutorials","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/nodejs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/nodejs\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/nodejs\/author\/kindsonthegenius-3\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/posts\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/comments?post=66"}],"version-history":[{"count":4,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/posts\/66\/revisions"}],"predecessor-version":[{"id":120,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/posts\/66\/revisions\/120"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/media\/68"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/media?parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/categories?post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/nodejs\/wp-json\/wp\/v2\/tags?post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}