<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vasyl K. on Medium]]></title>
        <description><![CDATA[Stories by Vasyl K. on Medium]]></description>
        <link>https://medium.com/@vasakorol?source=rss-2d88440feb4d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cDaY0zifqIktMaLY.</url>
            <title>Stories by Vasyl K. on Medium</title>
            <link>https://medium.com/@vasakorol?source=rss-2d88440feb4d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 02:29:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vasakorol/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[⚡ Angular’s New input() and output() APIs: Reactive Signals for Smarter Components]]></title>
            <link>https://medium.com/@vasakorol/angulars-new-input-and-output-apis-reactive-signals-for-smarter-components-00e91f97f3f0?source=rss-2d88440feb4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/00e91f97f3f0</guid>
            <category><![CDATA[angualr]]></category>
            <category><![CDATA[angular-signals]]></category>
            <category><![CDATA[angular-migration]]></category>
            <category><![CDATA[angular-input-output]]></category>
            <category><![CDATA[angular-input]]></category>
            <dc:creator><![CDATA[Vasyl K.]]></dc:creator>
            <pubDate>Mon, 30 Jun 2025 08:15:25 GMT</pubDate>
            <atom:updated>2025-06-30T08:15:25.759Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2MRCNEsb7Nqb9PUmFjS_Yw.png" /></figure><p><em>Angular 17 quietly introduced a shift in how we build components — one that could reshape how we write inputs and outputs forever.</em></p><h3>🏁 Introduction: What’s the Big Deal?</h3><p>When Angular announced signals, it wasn’t just another reactive library. It was a <em>foundational shift</em>.</p><p>Signals promised to replace Angular’s zone-based, often unpredictable change detection model with something <strong>precise, trackable, and intuitive</strong>.</p><p>But signals are more than just a new toy — they’re becoming the <strong>new default</strong>. And with the new input() and output() functions introduced in Angular 17.2, <strong>component APIs are finally catching up</strong>.</p><h3>🎯 Part 1: Classic Component Communication — What’s Broken?</h3><p>In pre-signal Angular, you probably wrote something like this:</p><pre>@Input() userId!: string;<br>@Output() saved = new EventEmitter&lt;User&gt;();</pre><p>This approach worked. But let’s be honest — it had quirks:</p><ul><li>@Input() is <strong>not reactive</strong>. You have to manually track changes using ngOnChanges() or use a setter.</li><li>EventEmitter is a weird hybrid — kind of observable, kind of not. It’s <em>not</em> part of RxJS and doesn’t integrate cleanly with signals or modern state systems.</li><li>Inputs and outputs aren’t composable — they’re just bindings, not values you can derive from or react to.</li></ul><p>You were working with <em>properties</em>, not <em>data flows</em>.</p><h3>🔁 Part 2: Enter Signals — And the New input() and output()</h3><p>With Angular signals, a new mental model is emerging: everything is a <em>reactive value</em>.</p><pre>import { input, output, signal, Component } from &#39;@angular/core&#39;;</pre><pre>@Component({<br>  selector: &#39;user-card&#39;,<br>  standalone: true,<br>  template: `&lt;p&gt;Hello, {{ name() }}!&lt;/p&gt;`<br>})<br>export class UserCardComponent {<br>  name = input&lt;string&gt;(); // signal&lt;string&gt;<br>}</pre><p>Here’s what changed:</p><ul><li>The input() function <strong>declares a signal</strong>, which automatically updates when the parent changes the input.</li><li>No need for setters, ngOnChanges, or workarounds.</li><li>You use name() just like any other signal.</li></ul><p>And output()?</p><pre>@Component({<br>  selector: &#39;user-form&#39;,<br>  standalone: true,<br>  template: `&lt;button (click)=&quot;submit()&quot;&gt;Submit&lt;/button&gt;`<br>})<br>export class UserFormComponent {<br>  private submittedSignal = signal&lt;User&gt;();<br>  submitted = output(this.submittedSignal);</pre><pre>  submit() {<br>    this.submittedSignal.set({ name: &#39;Alice&#39;, id: 1 });<br>  }<br>}</pre><p>No .emit(), no EventEmitter, and fully typed.</p><h3>🧪 Part 3: Migration in Practice</h3><p>Let’s say you have an old-school component:</p><pre>@Component({ ... })<br>export class LegacyModalComponent {<br>  @Input() visible = false;<br>  @Output() closed = new EventEmitter&lt;void&gt;();</pre><pre>  onClose() {<br>    this.closed.emit();<br>  }<br>}</pre><p>Here’s how to refactor it with signals:</p><pre>@Component({ ... })<br>export class SignalModalComponent {<br>  visible = input&lt;boolean&gt;(); // reactive input<br>  private closedSignal = signal&lt;void&gt;();<br>  closed = output(this.closedSignal); // reactive output</pre><pre>  onClose() {<br>    this.closedSignal.set();<br>  }<br>}</pre><h3>🔧 Part 4: Use Angular CLI to Migrate</h3><p>Angular CLI offers dedicated schematics to help migrate classic @Input() and @Output() properties to the new input() and output() signal APIs.</p><p>You can use the following commands:</p><pre>ng generate @angular/core:signal-input-migration<br>ng generate @angular/core:output-migration</pre><p>These schematics will:</p><ul><li>Convert @Input() properties to signal-based input() declarations</li><li>Convert @Output() EventEmitters to signal-based output() expressions</li><li>Apply changes only to <strong>standalone components</strong></li><li>Leave comments for edge cases that require manual attention (e.g., aliases, setters)</li></ul><p>This is the safest and fastest way to begin adopting signal-based inputs and outputs, and works best when paired with manual testing and code review.</p><h3>🧠 Part 5: Real-World Use Cases</h3><h4>1. Conditional UI Rendering</h4><pre>const shouldShowClose = computed(() =&gt; this.visible() &amp;&amp; this.userRole() === &#39;admin&#39;);</pre><p>In the old days, you’d manage this with multiple booleans, or worse, ngOnChanges.</p><p>Now? Just derive.</p><h4>2. Reactive Forms with Output</h4><pre>formData = signal&lt;FormData&gt;();<br>submitted = output(this.formData);</pre><pre>onSubmit() {<br>  this.formData.set(this.form.value);<br>}</pre><p>No event emitters, just signal flow.</p><h3>⚠️ Part 6: What You Should Know</h3><ul><li><strong>Standalone-only</strong>: input() and output() only work in standalone components.</li><li><strong>You can’t two-way bind</strong> signal inputs (yet)</li><li><strong>Interop needed</strong>: Mixing classic and signal inputs/outputs can cause friction. For now, transition gradually.</li></ul><h3>📌 Bonus Tip: Default Values for Inputs</h3><p>Want an input with a default? Just pass it in:</p><pre>theme = input&lt;&#39;light&#39; | &#39;dark&#39;&gt;(&#39;light&#39;); // Default is &#39;light&#39;</pre><p>Simple, elegant, and no need to check undefined in your templates.</p><h3>🔄 Part 7: Reacting to Input Changes — Then and Now</h3><p>Angular devs have long used <strong>setters </strong>to run logic when a value changes:</p><h4>⛔ Classic: @Input() set + Manual Tracking</h4><pre>@Component({ ... })<br>export class ProfileCardComponent {<br>  private _userId!: string;</pre><pre>  @Input()<br>  set userId(value: string) {<br>    this._userId = value;<br>    this.loadUserProfile(value);<br>  }</pre><pre>  get userId(): string {<br>    return this._userId;<br>  }</pre><pre>  loadUserProfile(id: string) {<br>    // call API or update state<br>  }<br>}</pre><h4>✅ Modern: input() + effect()</h4><pre>import { Component, input, effect } from &#39;@angular/core&#39;;</pre><pre>@Component({ ... })<br>export class ProfileCardComponent {<br>  userId = input&lt;string&gt;();</pre><pre>  constructor() {<br>    effect(() =&gt; {<br>      const id = this.userId();<br>      this.loadUserProfile(id);<br>    });<br>  }</pre><pre>  loadUserProfile(id: string) {<br>    // Fetch user<br>  }<br>}</pre><h3>🧮 Bonus: Using computed() with input() for Derived State</h3><pre>role = input&lt;string&gt;();<br>username = input&lt;string&gt;();</pre><pre>userLabel = computed(() =&gt; `${this.role()}: ${this.username()}`);</pre><p>Use in template:</p><pre>&lt;p&gt;{{ userLabel() }}&lt;/p&gt;</pre><p>Or track changes:</p><pre>effect(() =&gt; {<br>  console.log(&#39;User label changed:&#39;, this.userLabel());<br>});</pre><h3>✅ Final Combined Example</h3><pre>@Component({ ... })<br>export class ProfileCardComponent {<br>  userId = input&lt;string&gt;();<br>  role = input&lt;string&gt;();<br>  username = input&lt;string&gt;();</pre><pre>  userLabel = computed(() =&gt; `${this.role()}: ${this.username()}`);</pre><pre>  constructor() {<br>    effect(() =&gt; {<br>      this.loadUserProfile(this.userId());<br>    });</pre><pre>    effect(() =&gt; {<br>      console.log(&#39;User label changed:&#39;, this.userLabel());<br>    });<br>  }</pre><pre>  loadUserProfile(id: string) {<br>    // Fetch data based on userId<br>  }<br>}</pre><h3>🧭 Part 8: Where This Is Going</h3><p>Angular isn’t just patching old APIs. They’re rebuilding the reactive core from the ground up.</p><ul><li>Signals already power fine-grained change detection.</li><li>effect(), computed(), and signal() let you model your UI like reactive functions.</li><li>Now, input() and output() are catching up — turning your component’s API into part of the reactive graph.</li></ul><p>Soon, Angular templates might run outside of zones entirely, and change detection could become opt-in and blazing fast.</p><p>This is a <strong>transition moment</strong>, not a quick fix.</p><h3>🧳 Conclusion: Should You Switch?</h3><p>If you’re building new standalone components — <strong>yes</strong>. Use input() and output().</p><p>If you’re maintaining legacy apps — it’s okay to wait. But be aware: <strong>signals are Angular’s future</strong>. Adopting them now means less refactoring later.</p><p>And the DX (developer experience) is honestly fantastic.</p><h3>💬 Let’s Talk</h3><p>Have you tried input()/output() yet? What’s your experience with migrating from @Input()/@Output()?</p><p>Drop a comment, question, or challenge below — and if you’re deep into signals, I’d love to hear what patterns work best in your apps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00e91f97f3f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>