{"id":5304,"date":"2022-09-28T10:35:28","date_gmt":"2022-09-28T14:35:28","guid":{"rendered":"https:\/\/www.cloudsurph.com\/?p=5304"},"modified":"2022-09-28T10:36:30","modified_gmt":"2022-09-28T14:36:30","slug":"defining-the-adonisjs-events-and-listeners-module","status":"publish","type":"post","link":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/","title":{"rendered":"AdonisJS: Events and Listeners"},"content":{"rendered":"<p>In this article, we will learn about Defining the AdonisJS Events and Listeners Module, how Adonis supports these Events and Listeners Module, and how to define these Events and Listeners Module.<\/p>\n<h2>AdonisJS Events and Listeners<\/h2>\n<p>The events module differs from the Node.js native Events module and the AdonisJS event emitter module is created on top of <a href=\"https:\/\/github.com\/sindresorhus\/emittery\">Emittery<\/a> in the following ways.<\/p>\n<ul>\n<li>The events module is asynchronous, whereas the Node.js events module emits events synchronously. So, you can read also <a href=\"https:\/\/github.com\/sindresorhus\/emittery#how-is-this-different-than-the-built-in-eventemitter-in-nodejs\">the Emittery<\/a> explanation on this as well for sure.<\/li>\n<li>The events module Ability to make events type-safe.<\/li>\n<li>The events module Ability to trap events during tests instead of triggering the actual event.<\/li>\n<\/ul>\n<h3>Usage<\/h3>\n<p>However, we can define the event listeners inside the <strong>start\/events.ts<\/strong> file. Also, we can create this file manually or run the following Ace command below.<\/p>\n<p><strong><em>You can check our previous article:\u00a0<a href=\"https:\/\/www.cloudsurph.com\/adonisjs-rest-api-crud-setup\/\">AdonisJS: REST API simple CRUD Operation<\/a>. IF you want then buy a good, reliable, secure web\u00a0<a href=\"https:\/\/www.cloudsurph.com\/windows-vps-hosting\/\">hosting<\/a>\u00a0service \u00a0from here:\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">click here<\/a><\/em><\/strong><\/p>\n<pre class=\"prettyprint\">\r\nnode ace make:prldfile events\r\n\r\n# SELECT ALL THE ENVIRONMENTS\r\n<\/pre>\n<h5>Now, open the file that you created newly and write the following below code inside it.<\/h5>\n<p>The <strong>Event.on<\/strong> method registers as an event listener and it accepts the event name as the first argument, followed by a method to handle the event in the below code.<\/p>\n<pre class=\"prettyprint\">\r\nimport Event from '@ioc:Adonis\/Core\/Event'\r\n\r\nEvent.on('new:user', (user) =&gt; {\r\nconsole.log(user)\r\n})\r\n<\/pre>\n<p>You will have to emit this event to trigger the <strong>new:user <\/strong>event listener, and you can do it from anywhere inside your application after it has been booted as below code.<\/p>\n<pre class=\"prettyprint\">\r\nimport Event from '@ioc:Adonis\/Core\/Event'\r\n\r\nexport default class UsersController {\r\npublic async store() {\r\n\/\/ ... code to create a new user\r\nEvent.emit('new:user', { id: 1 })\r\n}\r\n}\r\n<\/pre>\n<h3>Making events type-safe<\/h3>\n<p>So, the event listeners and the code that emits the event are usually not in the same place or file.<\/p>\n<p>Therefore, it is a very easy way for some of your code to emit the event and send the wrong data. For example, like below:<\/p>\n<pre class=\"prettyprint\">\r\nEvent.on('new:user', (user) =&gt; {\r\nconsole.log(user.email)\r\n})\r\n\r\n\/\/ There is no email property defined here\r\nEvent.emit('new:user', { id: 1 })\r\n<\/pre>\n<p>Here, you can prevent this behavior by defining the argument&#8217;s type for a given event inside the contracts or the <strong>events.ts<\/strong> file.<\/p>\n<pre class=\"prettyprint\">\r\ndeclare module '@ioc:Adonis\/Core\/Event' {\r\ninterface EventsList {\r\n'new:user': { id: number; email: string }\r\n}\r\n}\r\n<\/pre>\n<p>Now, the TypeScript static compiler will ensure that all <strong>Event.emit<\/strong> calls for the <strong>new:user<\/strong> event is type-safe as in the below screenshot.<\/p>\n<h6><strong><em>Love to Code? We\u2019re Your Helping Partner,\u00a0<a href=\"https:\/\/www.cloudsurph.com\/love-to-code\/\">click here for<\/a>\u00a0\u00a0<a href=\"https:\/\/www.cloudsurph.com\/love-to-code\/\">Buy Our Service<\/a><\/em><\/strong><\/h6>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5305\" src=\"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module-type-safe-events.jpg\" alt=\"Defining the AdonisJS Events and Listeners Module\" width=\"1442\" height=\"670\" srcset=\"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module-type-safe-events.jpg 1442w, https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module-type-safe-events-1280x595.jpg 1280w, https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module-type-safe-events-980x455.jpg 980w, https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module-type-safe-events-480x223.jpg 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) and (max-width: 1280px) 1280px, (min-width: 1281px) 1442px, 100vw\" \/><\/p>\n<h3>Listener Classes<\/h3>\n<p>You can also extract the inline event listeners to their dedicated classes as Like controllers and middleware.<\/p>\n<p>However, we can customize the namespace inside the <strong>adonisrc.json<\/strong> file, and Conventionally event listeners are stored inside the <strong>app\/Listeners<\/strong> directory.<\/p>\n<h4>So, the customize event <strong>listeners<\/strong> namespace is as like:<\/h4>\n<pre class=\"prettyprint\">{\r\n\"namespaces\": {\r\n\"eventListeners\": \"App\/CustomDir\/Listeners\"\r\n}\r\n}\r\n<\/pre>\n<h5><em><strong>You can purchase your\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">hosting from Cloudsurph.com<\/a>,\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">Cloudsurph hosting<\/a>\u00a0is a reliable hosting option for business and personal projects. We offer insight and help on system configuration issues and code errors or bugs<\/strong>.<\/em><\/h5>\n<p>You can create a listener class by running the following Ace command below the code<\/p>\n<pre class=\"prettyprint\">\r\nnode ace make:listener User\r\n\r\n# CREATE: app\/Listeners\/User.ts\r\n<\/pre>\n<p>Now, open the newly created file and define the following method on the class like below.<\/p>\n<pre class=\"prettyprint\">\r\nimport { EventsList } from '@ioc:Adonis\/Core\/Event'\r\n\r\nexport default class User {\r\npublic async onNewUser(user: EventsList['new:user']) {\r\n\/\/ send email to the new user\r\n}\r\n}\r\n<\/pre>\n<p>Finally, we can bind the <strong>onNewUser<\/strong> method as the event listener inside the <strong>start\/events.ts<\/strong> file.<\/p>\n<p>So, the binding process is similar to a Route controller binding, and there is no need to define the complete namespace as below code<\/p>\n<pre class=\"prettyprint\">\r\nEvent.on('new:user', 'User.onNewUser')\r\n<\/pre>\n<h3>Error Handling<\/h3>\n<p>Since Emittery emits events asynchronously when you use the <strong>Event.emit<\/strong> method and the one way to handle the errors is to wrap your emit calls inside a <strong>try\/catch<\/strong> block like below<\/p>\n<pre class=\"prettyprint\">\r\ntry {\r\nawait Event.emit('new:user', { id: 1 })\r\n} catch (error) {\r\n\/\/ Handle error\r\n}\r\n<\/pre>\n<p>However, you should define the error handler only once following the below code<\/p>\n<pre class=\"prettyprint\">\r\nEvent.onError((event, error, eventData) =&gt; {\r\n\/\/ handle the error\r\n})\r\n<\/pre>\n<p>If you want to know more about AdonisJS Model relationships then please visit <a href=\"https:\/\/preview.adonisjs.com\/guides\/model-relations\/introduction\">AdonisJs<\/a> main website.<\/p>\n<p>If you enjoyed reading this article and have more questions please reach out to our\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/submitticket.php?step=2&amp;deptid=1\">support team<\/a>\u00a0via live chat or\u00a0<a href=\"mailto:support@cloudsurph.com\">email<\/a>\u00a0and we would be glad to help you. we provide server\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">hosting<\/a>\u00a0for all types of need and we can even get your\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">server<\/a>\u00a0up and running with the service of your choice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will learn about Defining the AdonisJS Events and Listeners Module, how Adonis supports these Events and Listeners Module, and how to define these Events and Listeners Module. AdonisJS Events and Listeners The events module differs from the Node.js native Events module and the AdonisJS event emitter module is created on top [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":5306,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[152,157,25,158,159,151,44,1],"tags":[54,47,105,103,48,113],"class_list":["post-5304","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-adonisjs","category-centos-7","category-web-hosting-virtualization","category-linux-basics","category-linux-server","category-react-js","category-kvm-xen","category-virtual-private-servers","tag-best-vps-hosting-server-maryland","tag-cheap-cloud-servers","tag-cheap-storage-server-hosting","tag-cheapest-vps","tag-dedicated-server-hosting-in-washington-d-c","tag-speed-test-vps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Defining the AdonisJS Events and Listeners Module<\/title>\n<meta name=\"description\" content=\"Defining AdonisJS Events Module, Defining the AdonisJS Events and Listeners Module, Usage, Making events, Listener classes, Error handling,\" \/>\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.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Defining the AdonisJS Events and Listeners Module\" \/>\n<meta property=\"og:description\" content=\"Defining AdonisJS Events Module, Defining the AdonisJS Events and Listeners Module, Usage, Making events, Listener classes, Error handling,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudsurph Web Hosting Washington D.C.\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/CloudSurph\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-28T14:35:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-28T14:36:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1264\" \/>\n\t<meta property=\"og:image:height\" content=\"760\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rony\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cloudsurph\" \/>\n<meta name=\"twitter:site\" content=\"@Cloud_Surph\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rony\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/\"},\"author\":{\"name\":\"Rony\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/person\\\/ac9b4dd136d96e50d5f29c560191e7ed\"},\"headline\":\"AdonisJS: Events and Listeners\",\"datePublished\":\"2022-09-28T14:35:28+00:00\",\"dateModified\":\"2022-09-28T14:36:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/\"},\"wordCount\":637,\"publisher\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/AdonisJS-Events-and-Listeners-Module.jpg\",\"keywords\":[\"Best VPS hosting server Maryland\",\"Cheap Cloud Servers\",\"Cheap Storage Server Hosting\",\"Cheapest VPS\",\"Dedicated Server Hosting in Washington D.C\",\"Speed test VPS\"],\"articleSection\":[\"AdonisJS\",\"CentOS 7\",\"Cloud Hosting\",\"Linux Basics\",\"Linux Server\",\"React Js\",\"Virtualization\",\"VPS Servers\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/\",\"name\":\"Defining the AdonisJS Events and Listeners Module\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/AdonisJS-Events-and-Listeners-Module.jpg\",\"datePublished\":\"2022-09-28T14:35:28+00:00\",\"dateModified\":\"2022-09-28T14:36:30+00:00\",\"description\":\"Defining AdonisJS Events Module, Defining the AdonisJS Events and Listeners Module, Usage, Making events, Listener classes, Error handling,\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/AdonisJS-Events-and-Listeners-Module.jpg\",\"contentUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/AdonisJS-Events-and-Listeners-Module.jpg\",\"width\":1264,\"height\":760},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/defining-the-adonisjs-events-and-listeners-module\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.cloudsurph.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AdonisJS: Events and Listeners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#website\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/\",\"name\":\"Cloudsurph Web Hosting Washington D.C.\",\"description\":\"Dedicated Server Hosting\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.cloudsurph.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\",\"name\":\"CloudSurph Technology Solutions\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/cloudsurph-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/cloudsurph-logo.png\",\"width\":2348,\"height\":1692,\"caption\":\"CloudSurph Technology Solutions\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/CloudSurph\\\/\",\"https:\\\/\\\/x.com\\\/Cloud_Surph\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/person\\\/ac9b4dd136d96e50d5f29c560191e7ed\",\"name\":\"Rony\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"caption\":\"Rony\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/cloudsurph\"],\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/author\\\/ron\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Defining the AdonisJS Events and Listeners Module","description":"Defining AdonisJS Events Module, Defining the AdonisJS Events and Listeners Module, Usage, Making events, Listener classes, Error handling,","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.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/","og_locale":"en_US","og_type":"article","og_title":"Defining the AdonisJS Events and Listeners Module","og_description":"Defining AdonisJS Events Module, Defining the AdonisJS Events and Listeners Module, Usage, Making events, Listener classes, Error handling,","og_url":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/","og_site_name":"Cloudsurph Web Hosting Washington D.C.","article_publisher":"https:\/\/www.facebook.com\/CloudSurph\/","article_published_time":"2022-09-28T14:35:28+00:00","article_modified_time":"2022-09-28T14:36:30+00:00","og_image":[{"width":1264,"height":760,"url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module.jpg","type":"image\/jpeg"}],"author":"Rony","twitter_card":"summary_large_image","twitter_creator":"@cloudsurph","twitter_site":"@Cloud_Surph","twitter_misc":{"Written by":"Rony","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/#article","isPartOf":{"@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/"},"author":{"name":"Rony","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/person\/ac9b4dd136d96e50d5f29c560191e7ed"},"headline":"AdonisJS: Events and Listeners","datePublished":"2022-09-28T14:35:28+00:00","dateModified":"2022-09-28T14:36:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/"},"wordCount":637,"publisher":{"@id":"https:\/\/www.cloudsurph.com\/#organization"},"image":{"@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module.jpg","keywords":["Best VPS hosting server Maryland","Cheap Cloud Servers","Cheap Storage Server Hosting","Cheapest VPS","Dedicated Server Hosting in Washington D.C","Speed test VPS"],"articleSection":["AdonisJS","CentOS 7","Cloud Hosting","Linux Basics","Linux Server","React Js","Virtualization","VPS Servers"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/","url":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/","name":"Defining the AdonisJS Events and Listeners Module","isPartOf":{"@id":"https:\/\/www.cloudsurph.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/#primaryimage"},"image":{"@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module.jpg","datePublished":"2022-09-28T14:35:28+00:00","dateModified":"2022-09-28T14:36:30+00:00","description":"Defining AdonisJS Events Module, Defining the AdonisJS Events and Listeners Module, Usage, Making events, Listener classes, Error handling,","breadcrumb":{"@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/#primaryimage","url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module.jpg","contentUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/09\/AdonisJS-Events-and-Listeners-Module.jpg","width":1264,"height":760},{"@type":"BreadcrumbList","@id":"https:\/\/www.cloudsurph.com\/defining-the-adonisjs-events-and-listeners-module\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cloudsurph.com\/"},{"@type":"ListItem","position":2,"name":"AdonisJS: Events and Listeners"}]},{"@type":"WebSite","@id":"https:\/\/www.cloudsurph.com\/#website","url":"https:\/\/www.cloudsurph.com\/","name":"Cloudsurph Web Hosting Washington D.C.","description":"Dedicated Server Hosting","publisher":{"@id":"https:\/\/www.cloudsurph.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cloudsurph.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.cloudsurph.com\/#organization","name":"CloudSurph Technology Solutions","url":"https:\/\/www.cloudsurph.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2016\/04\/cloudsurph-logo.png","contentUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2016\/04\/cloudsurph-logo.png","width":2348,"height":1692,"caption":"CloudSurph Technology Solutions"},"image":{"@id":"https:\/\/www.cloudsurph.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/CloudSurph\/","https:\/\/x.com\/Cloud_Surph"]},{"@type":"Person","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/person\/ac9b4dd136d96e50d5f29c560191e7ed","name":"Rony","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","caption":"Rony"},"sameAs":["https:\/\/x.com\/cloudsurph"],"url":"https:\/\/www.cloudsurph.com\/author\/ron\/"}]}},"_links":{"self":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/comments?post=5304"}],"version-history":[{"count":2,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5304\/revisions"}],"predecessor-version":[{"id":5308,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5304\/revisions\/5308"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/media\/5306"}],"wp:attachment":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/media?parent=5304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/categories?post=5304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/tags?post=5304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}