<?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: Mikita Himpel</title>
    <description>The latest articles on Forem by Mikita Himpel (@realoff).</description>
    <link>https://forem.com/realoff</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%2F1175373%2F4d479e3e-47e1-4a2a-93de-44ca193f2f0e.jpeg</url>
      <title>Forem: Mikita Himpel</title>
      <link>https://forem.com/realoff</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/realoff"/>
    <language>en</language>
    <item>
      <title>The Truth About Preloading in Modern Web</title>
      <dc:creator>Mikita Himpel</dc:creator>
      <pubDate>Sun, 01 Jun 2025 14:56:36 +0000</pubDate>
      <link>https://forem.com/realoff/the-truth-about-preloading-in-modern-web-23p0</link>
      <guid>https://forem.com/realoff/the-truth-about-preloading-in-modern-web-23p0</guid>
      <description>&lt;p&gt;One of the most common ways to optimize the size of an application's bundle is &lt;strong&gt;code splitting&lt;/strong&gt;. With code splitting, we divide the application into smaller chunks that can be loaded on demand. This allows us to reduce the amount of JavaScript that needs to be downloaded and parsed when the user first opens the app.&lt;/p&gt;

&lt;p&gt;A simple and widely used approach to code splitting is &lt;strong&gt;splitting by page&lt;/strong&gt;. The logic is straightforward: when a user opens &lt;em&gt;Page A&lt;/em&gt;, there’s no need to load the code for &lt;em&gt;Page B&lt;/em&gt; at that moment. This approach provides a significant improvement in initial load time, which is especially important for large applications.&lt;/p&gt;

&lt;p&gt;However, like any solution, this method comes with trade-offs. While first-time loading becomes faster, &lt;strong&gt;navigating between pages can feel slower&lt;/strong&gt;. When the user switches to a new page, there may be a noticeable delay between clicking a link or button and actually seeing the new content. This delay can negatively impact user experience, especially if the transition feels unresponsive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preloading to Improve Page Transitions
&lt;/h2&gt;

&lt;p&gt;To mitigate this issue, we can introduce &lt;strong&gt;preloading strategies&lt;/strong&gt;. The idea is to load certain chunks of code &lt;em&gt;before&lt;/em&gt; the user actually requests them, reducing or even eliminating the perceived delay during navigation.&lt;/p&gt;

&lt;p&gt;However, implementing an effective preloading strategy is not trivial. The main challenges are choosing &lt;strong&gt;what&lt;/strong&gt; to preload and &lt;strong&gt;when&lt;/strong&gt; to preload it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Timing Challenges
&lt;/h3&gt;

&lt;p&gt;One option is to preload chunks after a fixed timeout once the page is idle. But this approach is unreliable, as every user has a different internet connection, device performance, and interaction pattern. In some cases, preloading at the wrong moment can harm user experience — for example, if preloading starts while the user is actively interacting with the page, it may slow down ongoing interactions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mouseover and Touchstart Preloading
&lt;/h3&gt;

&lt;p&gt;Some frameworks apply &lt;strong&gt;mouseover-based preloading&lt;/strong&gt;: preloading starts when the user hovers over a link. This approach helps preload content shortly before it's needed and works reasonably well on desktop.&lt;/p&gt;

&lt;p&gt;However, it has limitations on mobile devices where no hover event exists. Some libraries therefore listen to &lt;code&gt;touchstart&lt;/code&gt; on mobile as a fallback. But even &lt;code&gt;touchstart&lt;/code&gt; happens very close to the actual navigation event — often too late to fully hide the loading delay, resulting in suboptimal UX.&lt;/p&gt;

&lt;h3&gt;
  
  
  Viewport-Based Strategies
&lt;/h3&gt;

&lt;p&gt;Another group of strategies is based on &lt;strong&gt;Intersection Observer&lt;/strong&gt; or simple viewport scanning. The idea is to preload links that are currently visible on screen or that are likely to be seen soon. Alternatively, one might preload &lt;em&gt;all&lt;/em&gt; links on the page shortly after the initial load.&lt;/p&gt;

&lt;p&gt;While these strategies help prioritize relevant links, they introduce new risks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If preloading starts too early, it may compete for resources with critical page content and degrade UX.&lt;/li&gt;
&lt;li&gt;If delayed too much, the preload may not complete before navigation.&lt;/li&gt;
&lt;li&gt;On pages with many links, preloading too aggressively may result in unnecessary bandwidth usage and increased memory consumption.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finding the right moment to start preloading remains difficult: we want to wait “a little bit” after the page has settled, but defining this "little bit" precisely is complicated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Browser Limitations
&lt;/h3&gt;

&lt;p&gt;One of the core challenges is that &lt;strong&gt;browsers give us very limited APIs to design truly smart preloading&lt;/strong&gt;. There is no reliable way to query network conditions or system load in advance. APIs like &lt;code&gt;requestIdleCallback&lt;/code&gt; help defer work during runtime idleness, but are not designed specifically for preloading, and don’t account for network bandwidth or user interactions.&lt;/p&gt;

&lt;p&gt;In practice, most preloading strategies rely on heuristics, which may or may not work well across different user scenarios.&lt;/p&gt;

&lt;h3&gt;
  
  
  Declarative vs. Imperative Navigation
&lt;/h3&gt;

&lt;p&gt;A key principle for enabling robust preloading is &lt;strong&gt;declarative navigation&lt;/strong&gt;. When navigation is declared via &lt;code&gt;&amp;lt;a href="..."&amp;gt;&lt;/code&gt; tags or dedicated &lt;code&gt;Link&lt;/code&gt; components, the system has full knowledge of possible navigation targets ahead of time. This allows frameworks to implement automatic preloading strategies behind the scenes.&lt;/p&gt;

&lt;p&gt;In contrast, when navigation is implemented imperatively (e.g. via custom JavaScript function calls like &lt;code&gt;navigateTo(url)&lt;/code&gt;), it becomes much harder — or even impossible — to build generalized preloading logic without manually instrumenting every possible navigation trigger.&lt;/p&gt;

&lt;p&gt;Declarative navigation should always be preferred not only for maintainability, but also because it opens the door for better UX optimizations like preloading.&lt;/p&gt;

&lt;p&gt;If your framework supports declarative routing via &lt;code&gt;Link&lt;/code&gt; components (or even plain &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;), and you stick to this declarative model, even if the framework doesn’t provide built-in preloading strategies — it's usually possible to implement your own preloading layer with reasonable effort.&lt;/p&gt;

&lt;h3&gt;
  
  
  Legacy Codebases &amp;amp; Imperative Navigation
&lt;/h3&gt;

&lt;p&gt;However, if you already have a large codebase heavily relying on imperative navigation, adding preloading becomes much harder. In such cases, you typically have to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Apply heuristics (e.g. manually preload certain key pages after a delay);&lt;/li&gt;
&lt;li&gt;Manually instrument navigation calls to inject preloading;&lt;/li&gt;
&lt;li&gt;Accept that fully automated preloading may not be feasible without architectural refactoring.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Preloading Support Across Frameworks
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Framework&lt;/th&gt;
&lt;th&gt;Preloading Triggers&lt;/th&gt;
&lt;th&gt;Global Configuration&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SvelteKit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;mouseover&lt;/code&gt;, &lt;code&gt;touchstart&lt;/code&gt;, &lt;code&gt;viewport (IntersectionObserver)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;Multiple built-in strategies; globally configurable.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TanStack Router&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;mouseover&lt;/code&gt;, &lt;code&gt;touchstart&lt;/code&gt;, &lt;code&gt;viewport (IntersectionObserver)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;Rich set of built-in strategies; global configuration available.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Angular&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;After initial load (&lt;code&gt;PreloadAllModules&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;⚠️ Yes (only global strategy)&lt;/td&gt;
&lt;td&gt;Has one built-in strategy that preloads all modules after initial load.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Vue Router&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;–&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;No built-in preloading; requires custom solutions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Nuxt.js&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;viewport&lt;/code&gt;, &lt;code&gt;interaction-based (hover, touchstart)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;Built-in preloading based on links and user interaction; globally configurable.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Next.js&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;viewport (prefetch in &amp;lt;Link&amp;gt;)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;⚠ Limited&lt;/td&gt;
&lt;td&gt;No way to fully configure strategy globally; per-link &lt;code&gt;prefetch&lt;/code&gt; attribute controls behavior.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;React Router&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;viewport&lt;/code&gt;, &lt;code&gt;interaction-based (hover, touchstart)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;Supports preloading per &lt;code&gt;&amp;lt;Link preload="..."&amp;gt;&lt;/code&gt;; no global configuration.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Code splitting helps optimize bundle size but introduces navigation delays.&lt;/li&gt;
&lt;li&gt;Preloading helps hide navigation delays but is tricky to implement well.&lt;/li&gt;
&lt;li&gt;Timing and link selection are two biggest challenges in preloading design.&lt;/li&gt;
&lt;li&gt;Declarative navigation significantly simplifies adding preloading strategies.&lt;/li&gt;
&lt;li&gt;Framework support varies widely — some offer global preloading, some offer none.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>frontend</category>
      <category>performance</category>
    </item>
    <item>
      <title>Integrating Angular with Storybook: Conquering React Version Complexities</title>
      <dc:creator>Mikita Himpel</dc:creator>
      <pubDate>Fri, 19 Jan 2024 18:57:33 +0000</pubDate>
      <link>https://forem.com/realoff/integrating-angular-with-storybook-conquering-react-version-complexities-26pl</link>
      <guid>https://forem.com/realoff/integrating-angular-with-storybook-conquering-react-version-complexities-26pl</guid>
      <description>&lt;p&gt;In the dynamic landscape of web development, integrating diverse frameworks and libraries is a common practice, yet it often brings compatibility challenges. This article presents a case study on an integration issue between Angular, Storybook, and React, shedding light on the specific problem arising from React's version flexibility and how it impacts Angular components when themes are switched in Storybook.&lt;/p&gt;

&lt;p&gt;Certainly, let's revise the introduction to specifically mention the errors being addressed within the article. Here's how the updated introduction could read:&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;In the multifaceted world of web development, integrating diverse frameworks and libraries is a common endeavor that often introduces compatibility challenges. This article presents a case study on a particularly intricate issue encountered when integrating Angular with Storybook in the context of varying React versions. Specifically, this study sheds light on the resolution of two prevalent errors encountered during theme switching in Storybook:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;ERROR Error: NG05104: The selector "SELECTOR_NAME" did not match any elements.&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;StorybookWrapperComponent.js:1 NG0912: Component ID generation collision detected.&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The article delves deep into the challenges posed by the flexibility of React version compatibility in Storybook, its implications for Angular components, and a strategic approach to resolving these specific errors, ensuring smoother integration and a more predictable development environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Challenge: React Version Flexibility and Angular Component Behavior
&lt;/h3&gt;

&lt;p&gt;While Storybook's configuration is designed to accommodate a range of React versions, this flexibility can inadvertently introduce issues:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"peerDependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^16.8.0 || ^17.0.0 || ^18.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^16.8.0 || ^17.0.0 || ^18.0.0"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem becomes evident when switching themes in Storybook, an action that triggers a re-render of the Angular component's wrapper. React versions 17 and 18 demonstrate divergent behaviors in this context:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;React 17:&lt;/strong&gt; Remounts the wrapper, causing the Angular component to reinitialize and redeclare.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React 18:&lt;/strong&gt; Does not remount the wrapper, avoiding the issue seen in React 17.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The remounting in React 17 leads to errors, specifically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR Error: NG05104: The selector "SELECTOR_NAME" did not match any elements.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;StorybookWrapperComponent.js:1 NG0912: Component ID generation collision detected.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These errors indicate a selector mismatch and a component ID collision, issues stemming from the remounting and reinitialization process.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Solution: Precise React Version Specification and Implementation
&lt;/h3&gt;

&lt;p&gt;To address this issue, we implemented a more precise specification of the React version in our &lt;code&gt;package.json&lt;/code&gt;. By introducing the following &lt;code&gt;overrides&lt;/code&gt;, we ensured the consistent behavior of the components regardless of the broader &lt;code&gt;peerDependencies&lt;/code&gt; range:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"overrides"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"18.2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"18.2.0"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This strategy effectively aligns the React version used by Storybook with the one that best suits our application's needs, mitigating the re-rendering discrepancies and the ensuing errors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;This case study underscores the nuanced challenges that can emerge when integrating multiple technologies, particularly when version flexibility leads to inconsistent behavior across different environments. By pinpointing the root cause of such issues and enacting targeted solutions, developers can navigate these complexities, ensuring smoother, more predictable interactions between the integrated components. The approach detailed here exemplifies how a nuanced understanding of the technologies involved and a strategic implementation can effectively resolve compatibility challenges, paving the way for more robust and reliable application development.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>storybook</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Sentry Web Vitals: Unpacking and Resolving LCP Metric Detection Challenges</title>
      <dc:creator>Mikita Himpel</dc:creator>
      <pubDate>Wed, 04 Oct 2023 14:58:39 +0000</pubDate>
      <link>https://forem.com/realoff/sentry-web-vitals-unpacking-and-resolving-lcp-metric-detection-challenges-3l7c</link>
      <guid>https://forem.com/realoff/sentry-web-vitals-unpacking-and-resolving-lcp-metric-detection-challenges-3l7c</guid>
      <description>&lt;p&gt;For those unacquainted, Sentry isn't just a tool for error monitoring. It's a robust platform that also allows for the measurement and analysis of web vitals metrics. These metrics provide tangible insights into the performance of web applications from the end-user's perspective. As we move deeper into the digital age, understanding and optimizing for user-centric metrics becomes paramount to delivering a top-notch user experience. However, while these metrics are designed to reflect real-world user interactions, they employ heuristics in their measurements. And inherently, heuristic approaches, though efficient, aren't always flawless. This brings us to the challenges and nuances of the Largest Contentful Paint (LCP) metric detection in Sentry, as we detail below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Background&lt;/strong&gt;:&lt;br&gt;
Recently, we encountered an issue with the LCP metric detection in Sentry. If you're not familiar with the LCP, it's a core web vital metric that represents the point in the page load timeline when the largest content element of a page is likely visible to users. Having this metric is crucial in understanding how well our application is performing from a user's perspective.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;: &lt;br&gt;
The LCP metric in Sentry wasn't behaving as expected. After diving deep into the operational aspects of this metric within Sentry, we identified the root cause. In our application, we remove the loading splash screen only after all resources have loaded and we receive the server response with some data. The Sentry transaction, however, is dispatched after the "load" event on the page, combined with specific Sentry processes and an &lt;code&gt;idleTimeout&lt;/code&gt; set to the default 1000ms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution&lt;/strong&gt;: &lt;br&gt;
To give the content enough time to render on the page, we opted to adjust the &lt;code&gt;idleTimeout&lt;/code&gt; parameter. This modification ensures that the "pageload" transaction in Sentry is dispatched later, allowing the primary content enough time to become visible.&lt;/p&gt;

&lt;p&gt;Additionally, through experimentation, we discovered that older versions of Sentry only collect the LCP metric after a user interaction, particularly a click on an interactive element. This means, after our changes, the LCP metric will be captured only if a user interacts with an element within the &lt;code&gt;idleTimeout&lt;/code&gt; duration post page load.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What’s Next?&lt;/strong&gt;: &lt;br&gt;
The good news is that the latest version of Sentry rectifies this limitation. Upon updating Sentry, the LCP metric will be automatically recorded at the end of the “pageload” transaction. Following this, the metric will be noted even if the user hasn't interacted with the page.&lt;/p&gt;

&lt;p&gt;In conclusion, while web vitals metrics offer invaluable insights, understanding their nuances and ensuring accurate setups can greatly improve the user experience. If you've been grappling with Sentry's LCP metric, consider revisiting your &lt;code&gt;idleTimeout&lt;/code&gt; settings and updating to the latest version.&lt;/p&gt;

&lt;p&gt;With the new version of Sentry, the LCP metric is recorded automatically at the end of the "pageload" transaction. However, in our specific scenario, adjusting the &lt;code&gt;idleTimeout&lt;/code&gt; remains imperative. Without it, the transaction would conclude prematurely. This is primarily because, in our application design, we remove the loading splash screen only after receiving pertinent data from the backend. This makes the &lt;code&gt;idleTimeout&lt;/code&gt; adjustment a necessary step to ensure the LCP metric is captured accurately and reflects the true user experience.&lt;/p&gt;

&lt;p&gt;For a deeper dive into the technical specifics of this issue, consult the related &lt;a href="https://github.com/getsentry/sentry-javascript/issues/6742#issuecomment-1739351303"&gt;Sentry GitHub issue&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>sentry</category>
      <category>frontend</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Managing @Input Typing in Angular: A Perspective for Newcomers</title>
      <dc:creator>Mikita Himpel</dc:creator>
      <pubDate>Mon, 02 Oct 2023 21:19:28 +0000</pubDate>
      <link>https://forem.com/realoff/managing-input-typing-in-angular-a-perspective-for-newcomers-5g0m</link>
      <guid>https://forem.com/realoff/managing-input-typing-in-angular-a-perspective-for-newcomers-5g0m</guid>
      <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;Being relatively new to Angular, I've found myself pondering over how to work with &lt;code&gt;@Input&lt;/code&gt; typisation, especially in applications where strict null checks are enabled. Let me present the variants I've observed and then offer an approach I've been considering.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Variants:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Undefined Type&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nx"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Type&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This method does the job, but it also requires incorporating numerous 'if' conditions in the code, compromising its readability.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Asserting Input&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nx"&gt;field&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;A decent approach for Angular 15, where the input is mandatory. However, I've heard that Angular 16 won't present the same issues. There's also the risk that someone might initiate the input in the constructor, which might bypass any type or linting checks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Default Value Initialization&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nx"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This is feasible but isn't universally applicable.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From the official documentation, I've seen all three methods employed, leaving me sometimes perplexed as to why one was chosen over the others.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Proposed Approach:
&lt;/h3&gt;

&lt;p&gt;I'm thinking of a structure where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the input is mandatory: &lt;code&gt;field!: Type&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If it's optional: &lt;code&gt;field?: Type&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This method distinctly demarcates mandatory from optional inputs at the type level. Essentially, inputs should carry either a &lt;code&gt;!&lt;/code&gt; or &lt;code&gt;?&lt;/code&gt; sign.&lt;/p&gt;

&lt;p&gt;Now, there could be situations where the input is essential, but at the component's initialization phase, the value isn't available. For such scenarios, I suggest: &lt;code&gt;field!: Type | null&lt;/code&gt;. Analogously, for optional fields where data isn't ready during the component's initialization phase, we'd use: &lt;code&gt;field?: Type | null&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Look Back at React:
&lt;/h3&gt;

&lt;p&gt;Having previously coded in React, I didn't encounter such dilemmas in functional components. It was quite puzzling for me not to find a standardized solution for such a ubiquitous problem in Angular. It seems the issue stems from Angular's reliance on classes, which means inputs can't be initialized during the constructor phase. Interestingly, from my understanding, Vue 3 seems to have navigated away from this problem, albeit with a different strategy.&lt;/p&gt;

&lt;p&gt;I'd love to get your feedback on this. If you've found alternative solutions or have insights into why one approach might be better than the others, please share. Let's make this journey into Angular smoother for everyone who's new!&lt;/p&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
