<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sarathkumar</title>
    <description>The latest articles on DEV Community by sarathkumar (@sarath).</description>
    <link>https://dev.to/sarath</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F169822%2F1b9e216f-944d-457d-98f7-d3c38bed8505.png</url>
      <title>DEV Community: sarathkumar</title>
      <link>https://dev.to/sarath</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sarath"/>
    <language>en</language>
    <item>
      <title>Ember route's actions during Transitions</title>
      <dc:creator>sarathkumar</dc:creator>
      <pubDate>Thu, 08 Aug 2019 12:50:35 +0000</pubDate>
      <link>https://dev.to/sarath/ember-route-s-actions-during-transitions-59o4</link>
      <guid>https://dev.to/sarath/ember-route-s-actions-during-transitions-59o4</guid>
      <description>&lt;p&gt;When i was working with the EmberJS webApp, i got struck with case where i was hit by the error &lt;em&gt;Nothing handled the action 'alerthello'.&lt;/em&gt; 😔 &lt;/p&gt;

&lt;p&gt;Consider,&lt;/p&gt;

&lt;p&gt;I have a &lt;strong&gt;alerthello&lt;/strong&gt; action in the route named &lt;em&gt;test.js&lt;/em&gt; and a controller named &lt;em&gt;test.js&lt;/em&gt; with function &lt;strong&gt;triggerprinthello&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The controller part looks like: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fycgxk72ap7st92wk26oq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fycgxk72ap7st92wk26oq.png" alt="test-controller"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The route part looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffqendgiqixcdr7klixmv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffqendgiqixcdr7klixmv.png" alt="test-route"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Is this the entire code ?, nope it’s just a sample (you may steal the code if i showed them 😂)&lt;/p&gt;

&lt;p&gt;You may think who the hell in the world would write such a script, well i am that guy.&lt;/p&gt;

&lt;p&gt;Ok, let’s come to the point.&lt;/p&gt;

&lt;p&gt;I tried to execute the above code, instead of showing the alert it throwed the error.&lt;/p&gt;

&lt;p&gt;Then i dig into this thing, then i found something interesting (maybe 🤔 to me).&lt;/p&gt;

&lt;h2&gt;
  
  
  You know what i found ? 😲
&lt;/h2&gt;

&lt;p&gt;The thing is that the ember maintains a active route list (Based on which the bubbling happens). 🤔 &lt;/p&gt;

&lt;p&gt;When I transitioned from some &lt;strong&gt;Xroute&lt;/strong&gt; to &lt;strong&gt;testroute&lt;/strong&gt; ember won’t add the &lt;strong&gt;testroute&lt;/strong&gt; in the active Route List until transition is completed.&lt;/p&gt;

&lt;p&gt;In my case, &lt;strong&gt;setupcontroller&lt;/strong&gt; will call the function &lt;strong&gt;triggerprinthello&lt;/strong&gt; which in turn will search for the action &lt;strong&gt;alerthello&lt;/strong&gt; in the active route list, since the &lt;strong&gt;testroute&lt;/strong&gt;(still in transitioning state) is not yet listed in the &lt;em&gt;Active route List&lt;/em&gt;, so it will bubble till the &lt;strong&gt;application&lt;/strong&gt; route looking for the action (&lt;strong&gt;Ember:&lt;/strong&gt; did you forget to add the action thinking about your girlfriend) and then boom 💥 it throws the error.&lt;/p&gt;

&lt;p&gt;So, how did i solved this:&lt;/p&gt;

&lt;p&gt;In two ways,&lt;/p&gt;

&lt;p&gt;1) I handled the action in the controller itself.&lt;br&gt;
2) I handled the action in the &lt;strong&gt;didTransition&lt;/strong&gt; hook of the route. 😌 &lt;/p&gt;

&lt;p&gt;You may ask why did this crap is posted here, i thought this post might be somewhat helpful to others.&lt;/p&gt;

&lt;p&gt;Also, please share your thoughts if i am wrong at something, so that i could correct myself 😊.&lt;/p&gt;

</description>
      <category>ember</category>
      <category>route</category>
    </item>
  </channel>
</rss>
