<?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 piseysen on Medium]]></title>
        <description><![CDATA[Stories by piseysen on Medium]]></description>
        <link>https://medium.com/@piseysen?source=rss-3ecd0f6861f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*emWDbGyoOwYjUwfzPYuQVw.jpeg</url>
            <title>Stories by piseysen on Medium</title>
            <link>https://medium.com/@piseysen?source=rss-3ecd0f6861f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:54:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@piseysen/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[Migrating RxJS to Angular Signals]]></title>
            <link>https://medium.com/@piseysen/migrating-rxjs-to-angular-signals-1e4941f274ee?source=rss-3ecd0f6861f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e4941f274ee</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[piseysen]]></dc:creator>
            <pubDate>Sat, 29 Mar 2025 13:56:37 GMT</pubDate>
            <atom:updated>2025-03-29T14:24:49.071Z</atom:updated>
            <content:encoded><![CDATA[<p>Migrating to <strong>Angular Signals</strong> involves transitioning from traditional RxJS-based state management to Angular’s new <strong>reactive primitive</strong> for more predictable and efficient reactivity. Here’s how you can migrate step by step:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PdQcEVSdm4741X2XIK5vMA.png" /></figure><h3>1. Understanding Angular Signals</h3><p>Angular Signals provide a <strong>declarative, fine-grained reactivity model</strong> that eliminates unnecessary change detection cycles.</p><h3>Key Concepts</h3><ul><li><strong>Signals (</strong><strong>signal&lt;T&gt;)</strong> → Holds reactive state.</li><li><strong>Computed Signals (</strong><strong>computed())</strong> → Derive new values.</li><li><strong>Effects (</strong><strong>effect())</strong> → Side effects that run when dependent signals change.</li></ul><h3>2. Migrating from RxJS to Signals</h3><h3>Replacing BehaviorSubject or ReplaySubject</h3><p>If you’re using BehaviorSubject to hold state:</p><pre>export class ExampleService {<br>  private countSubject = new BehaviorSubject&lt;number&gt;(0);<br>  count$ = this.countSubject.asObservable();<br><br>  increment() {<br>    this.countSubject.next(this.countSubject.value + 1);<br>  }<br>}</pre><p>Refactor with Signals</p><pre>import { signal } from &#39;@angular/core&#39;;<br><br>export class ExampleService {<br>  count = signal(0);<br><br>  increment() {<br>    this.count.set(this.count() + 1);<br>  }<br>}</pre><p><strong>Benefits:</strong> No need to subscribe, no .next(), and fine-grained reactivity.</p><h3>3. Migrating Computed Values (computed())</h3><p>If you previously derived state using combineLatest():</p><pre>import { combineLatest, map } from &#39;rxjs&#39;;<br><br>const derived$ = combineLatest([this.a$, this.b$]).pipe(<br>  map(([a, b]) =&gt; a + b)<br>);</pre><p>Use computed() Instead</p><pre>import { computed } from &#39;@angular/core&#39;;<br><br>derived = computed(() =&gt; this.a() + this.b());</pre><p><strong>Benefits:</strong> No need for combineLatest, executes only when necessary.</p><h3>4. Handling Side Effects (effect())</h3><p>If you used tap() or subscribe() for side effects:</p><pre>this.someObservable$.subscribe(value =&gt; {<br>  console.log(&#39;New value:&#39;, value);<br>});</pre><p>Use effect() Instead</p><pre>import { effect } from &#39;@angular/core&#39;;<br><br>effect(() =&gt; {<br>  console.log(&#39;New value:&#39;, this.someSignal());<br>});</pre><p><strong>Benefits:</strong> Runs only when dependencies change, no need to unsubscribe.</p><h3>5. Updating Components</h3><p>If you were using the async pipe:</p><pre>&lt;p&gt;{{ count$ | async }}&lt;/p&gt;</pre><p>Now, just call the signal as a function:</p><pre>&lt;p&gt;{{ count() }}&lt;/p&gt;</pre><p><strong>Benefits:</strong> No async pipe, updates automatically.</p><h3>6. When to Keep RxJS?</h3><p>Keep RxJS for:</p><ul><li><strong>HTTP calls (</strong><strong>HttpClient.get() returns Observable)</strong></li><li><strong>WebSockets or real-time data streams</strong></li><li><strong>Complex async operations (</strong><strong>switchMap, </strong><strong>debounceTime)</strong></li></ul><h3>7. References</h3><ol><li><a href="https://angular.dev/guide/signals">https://angular.dev/guide/signals</a></li><li><a href="https://medium.com/@dipaksahirav/from-rxjs-to-signals-f9798426218b">https://medium.com/@dipaksahirav/from-rxjs-to-signals-f9798426218b</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e4941f274ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Generics in Typescript]]></title>
            <link>https://medium.com/@piseysen/understanding-generics-in-typescript-ed396b6eae99?source=rss-3ecd0f6861f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed396b6eae99</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[piseysen]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 15:06:06 GMT</pubDate>
            <atom:updated>2025-03-11T15:09:44.485Z</atom:updated>
            <content:encoded><![CDATA[<p>Generics are a powerful feature in TypeScript that enable developers to write flexible, reusable, and type-safe code. They allow functions, interfaces, and classes to work with different data types while maintaining strict type safety.</p><h3>Why Generics Matter for an Experienced Angular Developer</h3><p>With <strong>5 years of experience in Angular and TypeScript with multiple projects</strong>, mastering TypeScript generics is crucial for building <strong>scalable, maintainable, and highly reusable</strong> code. Generics empower developers to create <strong>flexible functions, interfaces, and classes</strong> that adapt to different data types while ensuring strong <strong>type safety</strong>. In an Angular project, generics help streamline <strong>API handling, form validations, state management, and reusable components</strong>.</p><h3>1. Understanding Generics</h3><p>Generics in TypeScript allow you to define components (functions, classes, or interfaces) that work with a variety of types instead of a single specific type.</p><h3>Why Use Generics?</h3><ul><li>Enables <strong>code reusability</strong> by making components adaptable to different types.</li><li>Provides <strong>type safety</strong> while still being flexible.</li><li>Reduces redundancy and improves maintainability.</li></ul><h3>Basic Syntax</h3><p>A generic type is defined using <strong>angle brackets (</strong><strong>&lt;T&gt;)</strong> where T represents a placeholder for the actual type.</p><pre>function identity&lt;T&gt;(arg: T): T {<br>  return arg;<br>}<br><br>const num = identity&lt;number&gt;(10); // Type: number<br>const str = identity&lt;string&gt;(&quot;Hello Pisey&quot;); // Type: string</pre><h3>2. Generic Functions</h3><h3>Single Generic Parameter</h3><pre>function wrapValue&lt;T&gt;(value: T): T {<br>  return value;<br>}<br><br>const wrappedString = wrapValue(&quot;TypeScript&quot;); // Type: string<br>const wrappedNumber = wrapValue(100); // Type: number</pre><p>Multiple Generic Parameters</p><pre>function pair&lt;K, V&gt;(key: K, value: V): [K, V] {<br>  return [key, value];<br>}<br><br>const result = pair(&quot;id&quot;, 123); // Type: [string, number]</pre><h3>Generic Constraints</h3><p>You can constrain a generic type using the extends keyword.</p><pre>function getLength&lt;T extends { length: number }&gt;(item: T): number {<br>  return item.length;<br>}<br><br>getLength(&quot;Hello&quot;); // Valid (string has length)<br>getLength([1, 2, 3]); // Valid (array has length)<br>// getLength(10); Error (number does not have length)</pre><h3>3. Generic Interfaces</h3><p>You can define generic interfaces to enforce type consistency.</p><h3>Basic Generic Interface</h3><pre>interface Box&lt;T&gt; {<br>  value: T;<br>}<br><br>const numberBox: Box&lt;number&gt; = { value: 42 };<br>const stringBox: Box&lt;string&gt; = { value: &quot;Hello Pisey&quot; };</pre><p>Generic Interface with Functions</p><pre>interface Transformer&lt;T, R&gt; {<br>  (input: T): R;<br>}<br><br>const stringToNumber: Transformer&lt;string, number&gt; = (input) =&gt; input.length;</pre><h3>4. Generic Classes</h3><p>Generics allow creating reusable class templates.</p><pre>class Storage&lt;T&gt; {<br>  private data: T[] = [];<br><br>  add(item: T): void {<br>    this.data.push(item);<br>  }<br><br>  getAll(): T[] {<br>    return this.data;<br>  }<br>}<br><br>const numberStorage = new Storage&lt;number&gt;();<br>numberStorage.add(10);<br>numberStorage.add(20);<br><br>const stringStorage = new Storage&lt;string&gt;();<br>stringStorage.add(&quot;Hello Pisey&quot;);<br>stringStorage.add(&quot;World X&quot;);</pre><h3>5. Generic Type Aliases</h3><p>Type aliases can also use generics.</p><pre>type ApiResponse&lt;T&gt; = {<br>  data: T;<br>  status: number;<br>};<br><br>const userResponse: ApiResponse&lt;{ id: number; name: string }&gt; = {<br>  data: { id: 1, name: &quot;Alice&quot; },<br>  status: 200,<br>};</pre><h3>6. Generic Utility Types</h3><p>TypeScript provides built-in utility types that leverage generics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xMZklSZTH9Oyj_9YGOMmZQ.png" /></figure><p>Example:</p><pre>interface User {<br>  id: number;<br>  name: string;<br>  email: string;<br>}<br><br>type PartialUser = Partial&lt;User&gt;; // All properties optional<br>type RequiredUser = Required&lt;PartialUser&gt;; // All properties required<br>type ReadOnlyUser = Readonly&lt;User&gt;; // All properties readonly<br>type UserPreview = Pick&lt;User, &quot;id&quot; | &quot;name&quot;&gt;; // Only id and name<br>type UserWithoutEmail = Omit&lt;User, &quot;email&quot;&gt;; // Remove email</pre><h3>7. Advanced Generic Techniques</h3><h3>Generic Defaults</h3><p>You can provide default types for generics.</p><pre>interface Response&lt;T = string&gt; {<br>  data: T;<br>}<br><br>const defaultResponse: Response = { data: &quot;Success&quot; }; // Defaults to string<br>const numberResponse: Response&lt;number&gt; = { data: 42 };</pre><p>Using keyof with Generics</p><pre>function getProperty&lt;T, K extends keyof T&gt;(obj: T, key: K): T[K] {<br>  return obj[key];<br>}<br><br>const user = { id: 1, name: &quot;Alice&quot; };<br>const userName = getProperty(user, &quot;name&quot;); // Type: string</pre><h3>8. Practical Use Cases</h3><h4>1. Generic API Response Handling</h4><pre>interface ApiResponse&lt;T&gt; {<br>  success: boolean;<br>  data: T;<br>}<br><br>async function fetchData&lt;T&gt;(url: string): Promise&lt;ApiResponse&lt;T&gt;&gt; {<br>  const response = await fetch(url);<br>  const data = await response.json();<br>  return { success: response.ok, data };<br>}<br><br>interface User {<br>  id: number;<br>  name: string;<br>}<br><br>fetchData&lt;User&gt;(&quot;https://api.example.com/user&quot;).then((res) =&gt; console.log(res.data));</pre><h4>2. Generic Component in Angular</h4><pre>@Component({<br>  selector: &quot;app-list&quot;,<br>  template: `&lt;div *ngFor=&quot;let item of items&quot;&gt;{{ item }}&lt;/div&gt;`,<br>})<br>export class ListComponent&lt;T&gt; {<br>  @Input() items: T[] = [];<br>}</pre><h3>Conclusion</h3><p>Mastering TypeScript generics empowers developers to write reusable, flexible, and type-safe code. By using generics, you can create functions, interfaces, classes, and type aliases that work seamlessly with multiple data types while maintaining strict type safety.</p><p>Key takeaways include:</p><ol><li><strong>Basic Understanding</strong> — Generics allow the creation of reusable code that adapts to different types without sacrificing type safety.</li><li><strong>Functions and Constraints</strong> — Functions can use generics to work with any type, and constraints (extends) help restrict the accepted types.</li><li><strong>Interfaces and Classes</strong> — Generics can be used in interfaces and classes to build reusable and scalable data structures.</li><li><strong>Utility Types and Advanced Techniques</strong> — TypeScript provides built-in generic utility types like Partial&lt;T&gt;, Omit&lt;T&gt;, and Pick&lt;T&gt; for common use cases. Advanced techniques such as keyof and default generics further improve flexibility.</li><li><strong>Real-world Applications</strong> — Generics play a crucial role in API handling, component-based frameworks like Angular, and scalable software development.</li></ol><p>By incorporating generics effectively, you can significantly enhance code reusability and maintainability while ensuring type safety in TypeScript applications.</p><h3>References</h3><ol><li><a href="https://www.typescriptlang.org/docs/handbook/2/generics.html">https://www.typescriptlang.org/docs/handbook/2/generics.html</a></li><li><a href="https://medium.com/@hizacharylee/typescript-generics-a-starters-handbook-7f4b70a628df">https://medium.com/@hizacharylee/typescript-generics-a-starters-handbook-7f4b70a628df</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed396b6eae99" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to Design UI with Flutter for beginner]]></title>
            <link>https://medium.com/@piseysen/design-ui-with-flutter-for-beginner-e0480d39ffa4?source=rss-3ecd0f6861f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0480d39ffa4</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[piseysen]]></dc:creator>
            <pubDate>Sun, 09 Mar 2025 14:30:53 GMT</pubDate>
            <atom:updated>2025-03-09T14:40:02.603Z</atom:updated>
            <content:encoded><![CDATA[<p>Flutter UI design is flexible and powerful, allowing you to create responsive and visually appealing applications. Since you’re experienced in frontend development, I’ll focus on best practices and practical implementation.</p><h3>1. Understanding Flutter UI Structure</h3><p>Flutter’s UI is built using <strong>widgets</strong>, which are either:</p><ul><li><strong>StatelessWidget</strong> (UI doesn’t change)</li><li><strong>StatefulWidget</strong> (UI updates based on state changes)</li></ul><h3>2. Setting Up Your Flutter UI Project</h3><ol><li>Install Flutter SDK and set up your environment.</li><li>Create a new Flutter project:</li></ol><pre>flutter create my_first_flutter_app<br>cd my_first_flutter_app</pre><p>3. Run the app:</p><pre>flutter run</pre><h3>3. UI Design Best Practices</h3><ul><li><strong>Use Material Design or Cupertino Widgets</strong> for platform-specific styles.</li><li><strong>Leverage Layout Widgets</strong> like Column, Row, Stack, and Container for responsive designs.</li><li><strong>Use Custom Themes</strong> to maintain a consistent look across the app.</li><li><strong>Optimize Performance</strong> by using const widgets where possible.</li></ul><h3>4. Sample Flutter UI Layout</h3><p>Here’s an example of a <strong>modern Flutter UI layout</strong> using Scaffold, AppBar, and Container:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() {<br>  runApp(MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Flutter UI for Biginner&#39;,<br>      theme: ThemeData(<br>        primarySwatch: Colors.blue,<br>      ),<br>      home: HomeScreen(),<br>    );<br>  }<br>}<br><br>class HomeScreen extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&#39;Flutter UI for Biginner&#39;)),<br>      body: Center(<br>        child: Container(<br>          padding: EdgeInsets.all(16),<br>          decoration: BoxDecoration(<br>            color: Colors.blue[100],<br>            borderRadius: BorderRadius.circular(12),<br>          ),<br>          child: Text(<br>            &#39;Hello, Flutter!&#39;,<br>            style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><h3>5. Responsive UI with MediaQuery &amp; LayoutBuilder</h3><p>For better responsiveness across different devices:</p><pre>double screenWidth = MediaQuery.of(context).size.width;<br>if (screenWidth &lt; 600) {<br>  return MobileLayout();<br>} else {<br>  return TabletLayout();<br>}</pre><p>Or using LayoutBuilder:</p><pre>LayoutBuilder(<br>  builder: (context, constraints) {<br>    if (constraints.maxWidth &lt; 600) {<br>      return MobileLayout();<br>    } else {<br>      return TabletLayout();<br>    }<br>  },<br>);</pre><h3>6. Using Tailwind-like Styles in Flutter</h3><p>Flutter doesn’t have Tailwind CSS, but you can use SizedBox, Padding, and BoxDecoration to style components.</p><p>Example:</p><pre>Container(<br>  padding: EdgeInsets.all(8),<br>  margin: EdgeInsets.symmetric(horizontal: 16),<br>  decoration: BoxDecoration(<br>    color: Colors.white,<br>    borderRadius: BorderRadius.circular(8),<br>    boxShadow: [<br>      BoxShadow(<br>        color: Colors.black12,<br>        blurRadius: 4,<br>        spreadRadius: 2,<br>      ),<br>    ],<br>  ),<br>)</pre><h3>7. State Management for UI</h3><p>For handling state, consider:</p><ul><li><strong>Provider</strong> (Lightweight &amp; Recommended)</li><li><strong>Riverpod</strong> (Modern Provider alternative)</li><li><strong>Bloc/Cubit</strong> (For complex state management)</li><li><strong>GetX</strong> (Minimal setup &amp; easy routing)</li></ul><p>Example with <strong>Provider</strong>:</p><pre>class CounterModel with ChangeNotifier {<br>  int _count = 0;<br>  int get count =&gt; _count;<br><br>  void increment() {<br>    _count++;<br>    notifyListeners();<br>  }<br>}</pre><h3>8. Animations for Better UI</h3><p>To add smooth animations:</p><pre>AnimatedContainer(<br>  duration: Duration(milliseconds: 300),<br>  width: _isExpanded ? 200 : 100,<br>  height: 50,<br>  color: Colors.blue,<br>)</pre><p>Or use Lottie for animated illustrations:</p><pre>Lottie.asset(&#39;assets/animation.json&#39;)</pre><h3>9. UI Packages to Enhance Design</h3><ul><li>google_fonts (Custom fonts)</li><li>lottie (Animations)</li><li>flutter_svg (SVG support)</li><li>carousel_slider (Image sliders)</li><li>flutter_staggered_grid_view (Masonry grids)</li></ul><p>Example using <strong>Google Fonts</strong>:</p><pre>import &#39;package:google_fonts/google_fonts.dart&#39;;<br><br>Text(<br>  &#39;Hello, Flutter!&#39;,<br>  style: GoogleFonts.poppins(fontSize: 20),<br>)</pre><h3>10. Implementing Dark Mode</h3><pre>ThemeData lightTheme = ThemeData.light();<br>ThemeData darkTheme = ThemeData.dark();</pre><p>Toggle with:</p><pre>MaterialApp(<br>  themeMode: ThemeMode.system,<br>  theme: lightTheme,<br>  darkTheme: darkTheme,<br>);</pre><h3>Conclusion</h3><p>Flutter provides a powerful and flexible framework for designing modern UI with widgets, themes, and animations. By following best practices such as using <strong>responsive layouts, state management, and custom themes</strong>, you can build beautiful, high-performance applications.</p><p>To summarize:<br> ✅ <strong>Use Material &amp; Cupertino widgets</strong> for native feel<br> ✅ <strong>Implement responsive UI</strong> with MediaQuery &amp; LayoutBuilder<br> ✅ <strong>Enhance UI with animations</strong> (Lottie, AnimatedContainer)<br> ✅ <strong>Optimize performance</strong> by using const widgets<br> ✅ <strong>Utilize state management</strong> (Provider, Riverpod, Bloc)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0480d39ffa4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>