{"id":179,"date":"2014-04-28T15:07:18","date_gmt":"2014-04-28T15:07:18","guid":{"rendered":"http:\/\/www.javascripttutorials.net\/?p=179"},"modified":"2020-05-04T23:53:02","modified_gmt":"2020-05-04T21:53:02","slug":"aspect-oriented-programming-aop-for-javascript","status":"publish","type":"post","link":"https:\/\/www.javascripttutorials.net\/aspect-oriented-programming-aop-for-javascript\/","title":{"rendered":"Aspect Oriented Programming (AOP) for Javascript"},"content":{"rendered":"<p>Loose coupling. Your web front-end has that, right? Your JavaScript is using pubsub, event emitters, and message buses! Guess again, you can do better. Aspect Oriented Programming (AOP) is a technique for augmenting the behavior of objects, methods, and functions non-invasively.<!--more--><\/p>\n<p>AOP adds new behaviors and modifies existing behaviors &#8220;from the outside&#8221;. Using AOP, it&#8217;s possible to create connections between components without either having any knowledge of the other and without any extra library dependencies in your code.<\/p>\n<p>While you may be familiar with AOP in Spring, you may not yet have applied it in JavaScript. In this talk, we&#8217;ll do just that. We&#8217;ll introduce simple techniques for applying AOP in pure JavaScript using no additional libraries, and then look at <a href=\"https:\/\/github.com\/cujojs\/meld\">meld.js<\/a>, the AOP library that powers <a href=\"http:\/\/cujojs.com\">Cujo.js<\/a>. We&#8217;ll work from simple examples of making connections between components to more sophisticated examples that integrate pubsub, message buses, etc. in a truly loosely coupled way.<\/p>\n<p><iframe loading=\"lazy\" title=\"AOP-ing your JavaScript\" width=\"730\" height=\"411\" src=\"https:\/\/www.youtube.com\/embed\/MoZgJY2IF4A?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Loose coupling. Your web front-end has that, right? Your JavaScript is using pubsub, event emitters, and message buses! Guess again, you can do better. Aspect Oriented Programming (AOP) is a technique for augmenting the behavior of objects, methods, and functions non-invasively.<\/p>\n","protected":false},"author":1,"featured_media":258,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-179","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/posts\/179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/comments?post=179"}],"version-history":[{"count":0,"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/posts\/179\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/media\/258"}],"wp:attachment":[{"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/media?parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/categories?post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javascripttutorials.net\/wp-json\/wp\/v2\/tags?post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}