<?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>Forem: Seyed Amir Mehrizi</title>
    <description>The latest articles on Forem by Seyed Amir Mehrizi (@frontdecoder).</description>
    <link>https://forem.com/frontdecoder</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%2F3563923%2F3d805dba-1b55-4099-b607-bccbff765b89.png</url>
      <title>Forem: Seyed Amir Mehrizi</title>
      <link>https://forem.com/frontdecoder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/frontdecoder"/>
    <language>en</language>
    <item>
      <title>Sharing Data Between Components in Angular</title>
      <dc:creator>Seyed Amir Mehrizi</dc:creator>
      <pubDate>Sun, 26 Oct 2025 11:54:29 +0000</pubDate>
      <link>https://forem.com/frontdecoder/sharing-data-between-components-in-angular-2ce2</link>
      <guid>https://forem.com/frontdecoder/sharing-data-between-components-in-angular-2ce2</guid>
      <description>&lt;p&gt;Hey everyone.&lt;/p&gt;

&lt;p&gt;As a dev, I’ve always found myself wrestling with the challenge of sharing data between components in my Angular projects—it’s one of those things you can’t escape! Based on my experience with the Angular framework, I’ve figured out three solid ways to tackle this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbyd6qxx1rlo4r11691w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbyd6qxx1rlo4r11691w.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First off, the old-school way: using @Input to pass data from a parent down to its child component. For the reverse—sending data back up—we lean on @Output. It’s pretty straightforward and works like a charm for parent-child setups.&lt;/p&gt;

&lt;p&gt;But what happens with unrelated components? Take a look at this diagram I threw together—it’s a real head-scratcher sometimes!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x5wy8nt6b7y8kof946k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x5wy8nt6b7y8kof946k.png" alt=" " width="800" height="450"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Luckily, there’s a way to sort this out. I’ve been digging into RxJS lately, and using a BehaviorSubject in a service has been a game-changer. Basically, you create a service, hook it up in your repo, and boom—data flows between those unrelated components like magic!&lt;/p&gt;

&lt;p&gt;I’ve gone deeper into this topic in a video I recently posted on YouTube, where I break it all down step-by-step. I’d really appreciate it if you’d check it out and let me know your thoughts or any questions you’ve got—drop ‘em in the comments! Thanks!&lt;/p&gt;

&lt;p&gt;video link is : [&lt;a href="https://www.youtube.com/watch?v=4narJ2vS4ck&amp;amp;t=14s" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=4narJ2vS4ck&amp;amp;t=14s&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>angular</category>
      <category>programming</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Master RxJS Error Handling Once and for All — 3 Core Strategies You Should Know</title>
      <dc:creator>Seyed Amir Mehrizi</dc:creator>
      <pubDate>Tue, 14 Oct 2025 07:45:46 +0000</pubDate>
      <link>https://forem.com/frontdecoder/master-rxjs-error-handling-once-and-for-all-3-core-strategies-you-should-know-2e43</link>
      <guid>https://forem.com/frontdecoder/master-rxjs-error-handling-once-and-for-all-3-core-strategies-you-should-know-2e43</guid>
      <description>&lt;p&gt;As developers, we often focus too much on the &lt;em&gt;happy path&lt;/em&gt; — the perfect scenario where everything works smoothly and no API ever fails.&lt;br&gt;&lt;br&gt;
But in the real world, one tiny error can derail your entire app from its destination.&lt;br&gt;&lt;br&gt;
Error handling in RxJS is one of those underrated concepts that even experienced Angular devs struggle with.&lt;br&gt;&lt;br&gt;
In this post (and the video linked below), I’ll break down &lt;strong&gt;3 core strategies&lt;/strong&gt; that can help you design a clean, scalable, and resilient RxJS Error Handling Architecture. &lt;/p&gt;

&lt;h2&gt;
  
  
  *&lt;em&gt;**Why Error Handling Matters&lt;/em&gt;*
&lt;/h2&gt;

&lt;p&gt;Every time an HTTP request fails or a stream throws an unexpected error, your app risks breaking the entire reactive chain.&lt;br&gt;&lt;br&gt;
Without proper handling, users end up facing blank screens, frozen UI, or inconsistent data.&lt;br&gt;
Error handling isn’t just about “catching” errors — it’s about &lt;strong&gt;controlling how your app recovers and communicates failure gracefully&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Strategy #1: Replace
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Replace strategy&lt;/strong&gt; means catching the error and replacing the failed observable with a &lt;strong&gt;safe fallback value&lt;/strong&gt; or a new observable — so the stream can continue gracefully.&lt;br&gt;
It’s perfect when you don’t want one error to break the entire chain.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.http.get('/api/products').pipe(&lt;br&gt;
  catchError(err =&amp;gt; {&lt;br&gt;
    console.warn('Error occurred, replacing with empty list:', err);&lt;br&gt;
    return of([]); // replace with a fallback value&lt;br&gt;
  })&lt;br&gt;
);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Keeps the UI functional&lt;br&gt;&lt;br&gt;
 But may hide deeper issues if overused  &lt;/p&gt;

&lt;p&gt;Use it when recovery is possible — for example, showing cached data or a default UI.&lt;/p&gt;




&lt;h2&gt;
  
  
  Strategy #2: Rethrow
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Rethrow strategy&lt;/strong&gt; lets the error &lt;strong&gt;bubble up&lt;/strong&gt; after logging or side effects —&lt;br&gt;&lt;br&gt;
so other parts of your app (like interceptors or global handlers) can manage it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.http.get('/api/orders').pipe(&lt;br&gt;
  catchError(err =&amp;gt; {&lt;br&gt;
    this.logger.log(err);&lt;br&gt;
    return throwError(() =&amp;gt; err); // rethrow to higher level&lt;br&gt;
  })&lt;br&gt;
);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Enables centralized/global handling&lt;br&gt;&lt;br&gt;
Be careful not to rethrow endlessly — always ensure the stream has a terminal point that handles it  &lt;/p&gt;

&lt;p&gt;Use it when you want consistent global handling logic (like redirecting to login on 401 errors).&lt;/p&gt;




&lt;h2&gt;
  
  
  Strategy #3: Retry
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Retry strategy&lt;/strong&gt; simply means “try again before giving up.”&lt;br&gt;&lt;br&gt;
It’s great for transient errors such as flaky network requests or slow APIs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.http.get('/api/data').pipe(&lt;br&gt;
  retry(3), // retry up to 3 times&lt;br&gt;
  catchError(err =&amp;gt; {&lt;br&gt;
    console.error('Failed after 3 retries:', err);&lt;br&gt;
    return throwError(() =&amp;gt; err);&lt;br&gt;
  })&lt;br&gt;
);&lt;/code&gt;&lt;br&gt;
Great for network resilience&lt;br&gt;&lt;br&gt;
Avoid retrying on logical or validation errors (e.g., 400 Bad Request)&lt;br&gt;&lt;br&gt;
You can also use &lt;code&gt;retryWhen&lt;/code&gt; for smarter logic (like exponential backoff or conditional retry).&lt;/p&gt;

&lt;h2&gt;
  
  
  Watch the Full Breakdown
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://youtu.be/lFCcanQMJBQ" rel="noopener noreferrer"&gt;Master RxJS Error Handling Once and for All | 3 Core Strategies (YouTube)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the video, I go deeper into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When to use each strategy
&lt;/li&gt;
&lt;li&gt;How to combine them effectively
&lt;/li&gt;
&lt;li&gt;Real-world examples from Angular apps &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;##  Discussion&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
How do &lt;em&gt;you&lt;/em&gt; handle errors in your RxJS or Angular projects?&lt;br&gt;&lt;br&gt;
I’d love to hear how you structure your error-handling logic — drop your thoughts below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;## Final Thoughts&lt;br&gt;
**&lt;br&gt;
Error handling isn’t just about preventing crashes — it’s about **designing predictable, maintainable, and resilient applications&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;If you found this helpful, consider following me here on Dev.to or checking out my YouTube channel for more Angular + RxJS insights&lt;br&gt;
🎬 &lt;a href="https://www.youtube.com/@frontDecoder" rel="noopener noreferrer"&gt;frontDecoder&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;*Thanks for reading and happy coding!&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>angular</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
