<?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: Sashikumar Yadav</title>
    <description>The latest articles on DEV Community by Sashikumar Yadav (@yshashi30).</description>
    <link>https://dev.to/yshashi30</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%2F3580599%2F077a605d-7162-4972-bb5d-78baf2e0b195.jpg</url>
      <title>DEV Community: Sashikumar Yadav</title>
      <link>https://dev.to/yshashi30</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yshashi30"/>
    <language>en</language>
    <item>
      <title>RXJS interview question</title>
      <dc:creator>Sashikumar Yadav</dc:creator>
      <pubDate>Sat, 29 Nov 2025 19:31:31 +0000</pubDate>
      <link>https://dev.to/yshashi30/rxjs-interview-question-b2</link>
      <guid>https://dev.to/yshashi30/rxjs-interview-question-b2</guid>
      <description>&lt;p&gt;This is my sample blog&lt;/p&gt;

</description>
      <category>angular</category>
      <category>interview</category>
      <category>webdev</category>
      <category>ai</category>
    </item>
    <item>
      <title>What Are Tokens in GPT</title>
      <dc:creator>Sashikumar Yadav</dc:creator>
      <pubDate>Thu, 23 Oct 2025 22:24:24 +0000</pubDate>
      <link>https://dev.to/yshashi30/what-are-tokens-in-gpt-4360</link>
      <guid>https://dev.to/yshashi30/what-are-tokens-in-gpt-4360</guid>
      <description>&lt;p&gt;If you’ve ever played around with ChatGPT or any large language model, you might’ve heard the word “token” thrown around — usually when someone talks about limits or pricing. But what exactly are tokens?&lt;/p&gt;

&lt;p&gt;Think of tokens as the smallest pieces of text an AI understands. They’re not always full words — sometimes just parts of them.&lt;br&gt;
For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“ChatGPT is awesome!”&lt;br&gt;
might be broken down into tokens like: Chat, G, PT, is, awesome!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The model doesn’t actually “see” sentences the way we do. It sees a long chain of these tokens and tries to predict what comes next — that’s how it builds responses.&lt;/p&gt;

&lt;p&gt;Why does it matter? Because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tokens decide how long your input or output can be (there’s always a token limit).&lt;/li&gt;
&lt;li&gt;Tokens also determine cost — AI tools charge based on how many tokens you use.&lt;/li&gt;
&lt;li&gt;And finally, they define context — the more tokens the model can process, the more it can “remember” in a conversation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, tokens are like the currency of understanding in the AI world. Every question, answer, and word you type is made up of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fun fact:&lt;/strong&gt; the latest GPT models can handle over 128,000 tokens at once — roughly the length of a full novel. Imagine an AI reading an entire book and still remembering every detail — that’s the power of tokens.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>chatgpt</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Centralizing SVG Handling in Angular Applications</title>
      <dc:creator>Sashikumar Yadav</dc:creator>
      <pubDate>Thu, 23 Oct 2025 18:53:32 +0000</pubDate>
      <link>https://dev.to/yshashi30/centralizing-svg-handling-in-angular-applications-1jno</link>
      <guid>https://dev.to/yshashi30/centralizing-svg-handling-in-angular-applications-1jno</guid>
      <description>&lt;p&gt;SVG icons are essential for modern web UIs, but managing them directly in templates becomes challenging as applications grow. This post demonstrates how we implemented a scalable approach to SVG management in DevsWhoRun Angular application using modern directives and TypeScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Inline SVGs in templates lead to several issues:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button&amp;gt;&amp;lt;svg class="w-5 h-5" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&amp;gt;&amp;lt;path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438..." fill="currentColor"&amp;gt;&amp;lt;/path&amp;gt;&amp;lt;/svg&amp;gt;
  Sign in with GitHub
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Template Bloat: SVG markup clutters templates&lt;/li&gt;
&lt;li&gt;Duplication: Same SVGs repeated across components&lt;/li&gt;
&lt;li&gt;Inconsistency: Inconsistent rendering&lt;/li&gt;
&lt;li&gt;Maintenance: Updates require changes in multiple files&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Solution: A Centralized SVG Approach
&lt;/h2&gt;

&lt;p&gt;Our solution consists of two key components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A TypeScript constants file for SVG definitions&lt;/li&gt;
&lt;li&gt;An Angular directive for dynamic SVG rendering&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 1: Create the SVG Constants File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// svg-icon-constants.ts
import { Icon } from "./types";

// Type-safe icon name constants
export const ICON_NAME = {
  google: 'google',
  github: 'github',
  sun: 'sun',
  moon: 'moon',
  smile: 'smile',
  discord: 'discord'
}

// SVG path data mapped to icon names
export const SVG_ICONS: { [key: Icon]: string } = {
  [ICON_NAME.google]: `&amp;lt;svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&amp;gt;
    &amp;lt;path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"&amp;gt;&amp;lt;/path&amp;gt;
  &amp;lt;/svg&amp;gt;`,

  [ICON_NAME.github]: `&amp;lt;svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&amp;gt;
    &amp;lt;path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" fill="currentColor"&amp;gt;&amp;lt;/path&amp;gt;
  &amp;lt;/svg&amp;gt;`
  // Additional icons omitted for brevity
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create the SVG Icon Directive
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// svg-icon.ts
import { Directive, ElementRef, inject, input, OnInit, Renderer2 } from '@angular/core';
import { SVG_ICONS } from './svg-icon-constants';
import { Icon } from './types';

@Directive({
  selector: '[appSvgIcon]',
})
export class SvgIcon implements OnInit {
  // Modern Angular signals-based inputs
  iconName = input&amp;lt;Icon&amp;gt;('google');
  iconClass = input&amp;lt;string&amp;gt;('');
  fill = input&amp;lt;string&amp;gt;('currentColor');

  // Dependency injection using inject function
  ﻿private readonly el = inject(ElementRef);
  private readonly renderer = inject(Renderer2);

  ngOnInit(): void {
    if (!this.iconName() || !SVG_ICONS[this.iconName()]) {
      console.error(`SVG icon not found: ${this.iconName()}`);
      return;
    }

    const svgString = SVG_ICONS[this.iconName()];
    const parser = new DOMParser();
    const doc = parser.parseFromString(svgString, 'image/svg+xml');
    const svgElement = doc.documentElement;

    // Add CSS classes if provided
    ﻿if (this.iconClass()) {const classes = this.iconClass().split(' ');
      classes.forEach(className =&amp;gt; {
        if (className) {
          this.renderer.addClass(svgElement, className);
        }
      });
    }

    // Set fill color for all paths
    ﻿const paths = svgElement.querySelectorAll('path');
    paths.forEach(path =&amp;gt; {
      path.setAttribute('fill', this.fill());
    });

    // Append the SVG to the host element
   ﻿ this.renderer.setProperty(this.el.nativeElement, 'innerHTML','');
    this.renderer.appendChild(this.el.nativeElement, svgElement);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Create Type Definitions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// types.ts
import { ICON_NAME } from "./svg-icon-constants";

// Creates a union type of all icon name values
export type Icon = (typeof ICON_NAME)[keyof typeof ICON_NAME];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Using the SVG Directive in Components
&lt;/h3&gt;

&lt;p&gt;Implement the directive in any component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// footer.ts
import { Component } from '@angular/core';
import { SvgIcon } from '../../../shared/directives/svg/svg-icon';
import { ICON_NAME } from '../../../shared/directives/svg/svg-icon-constants';

@Component({
  selector: 'app-footer',
  imports: [SvgIcon],
  template: `
    &amp;lt;footer class="bg-gray-800 text-white py-8"&amp;gt;
      &amp;lt;div class="container mx-auto"&amp;gt;
        &amp;lt;div class="flex justify-center space-x-6"&amp;gt;
          &amp;lt;a href="https://github.com/yshashi/devswhomove" target="_blank" rel="noopener noreferrer"&amp;gt;
            &amp;lt;span appSvgIcon [iconName]="iconName.github" iconClass="w-6 h-6"&amp;gt;&amp;lt;/span&amp;gt;
          &amp;lt;/a&amp;gt;
          &amp;lt;a href="https://discord.gg/devswhomove" target="_blank" rel="noopener noreferrer"&amp;gt;
            &amp;lt;span appSvgIcon [iconName]="iconName.discord" iconClass="w-6 h-6"&amp;gt;&amp;lt;/span&amp;gt;
          &amp;lt;/a&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;p class="text-center mt-4"&amp;gt;© 2025 DevsWhoMove. All rights reserved.&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/footer&amp;gt;
  `,
  standalone: true
})
export class Footer {
  protected readonly iconName = ICON_NAME;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Technical Benefits
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Clean, Type-Safe Templates
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="https://github.com/yshashi/devswhomove" target="_blank"&amp;gt;
   ﻿&amp;lt;svg class="w-6 h-6" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&amp;gt;&amp;lt;path d="M12 .297c-6.63 0-12 5.373-    12 12 0 5.303 3.438 9.8 8.205 11.385..." fill="currentColor"&amp;gt;&amp;lt;/path&amp;gt;
   ﻿&amp;lt;/svg&amp;gt;
&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="https://github.com/yshashi/devswhomove" target="_blank"&amp;gt;
   ﻿&amp;lt;span appSvgIcon [iconName]="iconName.github" iconClass="w-6 h-6"&amp;gt;&amp;lt;/span&amp;gt;
&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Developer Experience Improvements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Type Safety: TypeScript interfaces ensure correct icon names&lt;/li&gt;
&lt;li&gt;Centralized Management: Single source of truth for all SVGs&lt;/li&gt;
&lt;li&gt;IDE Support: Autocomplete for icon names and properties&lt;/li&gt;
&lt;li&gt;Consistent Styling: Apply classes uniformly across all icons&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Performance Optimizations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Reduced Bundle Size: No duplicate SVG definitions&lt;/li&gt;
&lt;li&gt;Efficient DOM Operations: Directive handles optimal rendering&lt;/li&gt;
&lt;li&gt;Caching: Browser can cache SVG content&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advanced Implementation Options
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Server-Side Rendering Support
&lt;/h3&gt;

&lt;p&gt;For Angular Universal applications, ensure the directive works with SSR by checking the platform before performing DOM operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { PLATFORM_ID, inject } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';

// Modern dependency injection
private readonly platformId = inject(PLATFORM_ID);

ngOnInit(): void {
  // Only perform DOM operations in browser environment
﻿  if (isPlatformBrowser(this.platformId)) {
     // SVG parsing and DOM manipulation code
     ﻿const svgString = SVG_ICONS[this.iconName()];
     const parser = new DOMParser();
     // Rest of the implementation...
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Lazy Loading Icons by Feature
&lt;/h3&gt;

&lt;p&gt;For applications with many icons, implement lazy loading by feature using modern Angular patterns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// feature-icons.ts
import { InjectionToken } from '@angular/core';

// Create a token for feature-specific icons
export const FEATURE_ICONS = new InjectionToken&amp;lt;Record&amp;lt;string, string&amp;gt;&amp;gt;('FEATURE_ICONS');

// Define feature-specific icons
export const DASHBOARD_ICONS = {
  chart: `&amp;lt;svg viewBox="0 0 24 24"&amp;gt;...&amp;lt;/svg&amp;gt;`,
  analytics: `&amp;lt;svg viewBox="0 0 24 24"&amp;gt;...&amp;lt;/svg&amp;gt;`
};

// In your feature module or component providers
providers: [
  {
    provide: FEATURE_ICONS,
    useValue: DASHBOARD_ICONS
  }
]

// Inject in directive
const featureIcons = inject(FEATURE_ICONS, { optional: true });

// Merge with core icons
const allIcons = { ...SVG_ICONS, ...featureIcons };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Our centralized SVG handling approach in the DevsWhoRun Angular application demonstrates how modern Angular features like signals and functional dependency injection can create a clean, maintainable solution. By centralizing SVG definitions and using a directive for rendering, we've achieved:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improved Developer Experience: Type-safe icon references with IDE autocompletion&lt;/li&gt;
&lt;li&gt;Better Performance: Reduced bundle size and optimized rendering&lt;/li&gt;
&lt;li&gt;Enhanced Maintainability: Single source of truth for all SVG assets&lt;/li&gt;
&lt;li&gt;Flexible Styling: Dynamic class application and fill color control&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This pattern scales well from small applications to enterprise-level projects, providing a solid foundation for consistent icon usage across your Angular applications.&lt;/p&gt;

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