<?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: Sooraj (PS)</title>
    <description>The latest articles on DEV Community by Sooraj (PS) (@soorajsnblaze333).</description>
    <link>https://dev.to/soorajsnblaze333</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%2F429269%2F56e8537a-4e86-491f-a583-67f611232154.png</url>
      <title>DEV Community: Sooraj (PS)</title>
      <link>https://dev.to/soorajsnblaze333</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/soorajsnblaze333"/>
    <language>en</language>
    <item>
      <title>Moonlit Halloween: A CSS-Only Jack-o’-Lantern Under the Night Sky</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Sat, 08 Nov 2025 23:57:37 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/moonlit-halloween-a-css-only-jack-o-lantern-under-the-night-sky-4cc3</link>
      <guid>https://dev.to/soorajsnblaze333/moonlit-halloween-a-css-only-jack-o-lantern-under-the-night-sky-4cc3</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/frontend-2025-10-15"&gt;Frontend Challenge - Halloween Edition, CSS Art&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspiration
&lt;/h2&gt;

&lt;p&gt;I wanted to capture the cozy-but-spooky feeling of a Halloween night, a glowing jack-o’-lantern sitting under the moonlight.&lt;br&gt;
My inspiration came from classic animated Halloween scenes where the light from the pumpkin flickers softly, giving life to the night around it.&lt;br&gt;
Instead of relying on images or SVGs, I wanted to see how far I could push pure CSS gradients, pseudo-elements, and keyframe animations, to build something atmospheric and alive.&lt;/p&gt;
&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;

&lt;iframe height="600" src="https://codepen.io/SoorajSnBlz/embed/OPMKJLB?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;


&lt;/p&gt;

&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;p&gt;This started as a simple pumpkin, but once I nailed the shape and glow, I couldn’t stop adding details, a stem with gradient lighting, a pale moon with craters, a soft floor reflection.&lt;/p&gt;

&lt;p&gt;A few highlights from the build:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The pumpkin is entirely layered using CSS ellipses and gradients (no images).&lt;/li&gt;
&lt;li&gt;CSS variables helped me keep the color palette warm and cohesive.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Struggles
&lt;/h2&gt;

&lt;p&gt;Some of the struggles I faced when trying to make the tiny details are as follows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For the pumpkin tooth, I had to make sure that the transition between the tooth and different parts of the pumpkin. So I had to use a linear gradient at an angle to match the separations&lt;br&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%2Fa28wqhwuarsg6d7wrfe0.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%2Fa28wqhwuarsg6d7wrfe0.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Similarly for the smile, I was not able to make a crescent shape without using clip-path. I used the same principle of adding a mask using another element with an ellipse radial gradient to match the separation of the pumpkin&lt;br&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%2F3tfkme5w65rsp176ssc3.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%2F3tfkme5w65rsp176ssc3.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For the pumpkin stem I ended up using a clip-path with a similar radial gradient and another element to simulate the top of the stem&lt;br&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%2Fxg9x76w4udp8kr08xf2b.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%2Fxg9x76w4udp8kr08xf2b.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What I learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Layering gradients with opacity creates depth — even in flat, 2D art.&lt;/li&gt;
&lt;li&gt;You can achieve a surprisingly cinematic vibe with just a few lines of well-placed CSS.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next, I’d love to extend this into a looping CSS Halloween card,  with fog drifting, bats swooping, and the candle glow subtly pulsing in sync with the scene’s atmosphere.&lt;/p&gt;

&lt;p&gt;👻✨ Pure CSS can be magic when the lights go out!&lt;/p&gt;

</description>
      <category>frontendchallenge</category>
      <category>devchallenge</category>
      <category>css</category>
    </item>
    <item>
      <title>Frontend challenge</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Fri, 11 Jul 2025 14:14:56 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/frontend-challenge-8b1</link>
      <guid>https://dev.to/soorajsnblaze333/frontend-challenge-8b1</guid>
      <description></description>
      <category>frontendchallenge</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>challenge</category>
    </item>
    <item>
      <title>✨ A Tribute to Juneteenth – A Scroll Through History</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Fri, 13 Jun 2025 00:22:16 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/a-tribute-to-juneteenth-a-scroll-through-history-51io</link>
      <guid>https://dev.to/soorajsnblaze333/a-tribute-to-juneteenth-a-scroll-through-history-51io</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/frontend-2025-06-04"&gt;Frontend Challenge - June Celebrations, Perfect Landing: June Celebrations&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;For the June Frontend Challenge, I created a dynamic landing page commemorating Juneteenth — the powerful celebration of freedom in the United States. Rather than a static site, I wanted to take users on a scrolling timeline journey, visualizing key milestones in Juneteenth’s history through a blend of historic artwork and modern UI animations.&lt;/p&gt;

&lt;p&gt;The concept was simple: let the years roll by, and let the story unfold.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;You can find the Github Repository here: &lt;a href="https://github.com/SoorajSNBlaze333/juneteenth-2025-landing" rel="noopener noreferrer"&gt;https://github.com/SoorajSNBlaze333/juneteenth-2025-landing&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tech Stack used&lt;br&gt;
    • ⚡ Vite — for blazing fast dev server&lt;br&gt;
    • ⚛️ React — UI rendering&lt;br&gt;
    • 🎨 Tailwind CSS — utility-first styling&lt;br&gt;
    • 🌀 Framer Motion — animations and transitions&lt;/p&gt;

&lt;p&gt;The Live version is deployed here: &lt;a href="https://juneteenth-2025-landing.vercel.app/" rel="noopener noreferrer"&gt;https://juneteenth-2025-landing.vercel.app/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;p&gt;This challenge was my playground for deep-diving into Framer Motion — its ability to animate layouts and transitions is truly next level.&lt;/p&gt;

&lt;p&gt;I didn’t want just a “nice layout.” I wanted it to feel like history was scrolling past you — smooth, respectful, and elegant. So I layered in a few small but impactful touches:&lt;/p&gt;

&lt;p&gt;Thoughtful Details:&lt;br&gt;
    • 🎞️ Rolling year digits that flip as you scroll — adding rhythm to the timeline.&lt;br&gt;
    • 🔲 Grid-aligned sections with matching borders for a continuous visual thread.&lt;br&gt;
    • 🎯 Snap-to-center scrolling so each historical moment gets its spotlight.&lt;br&gt;
    • 🎹 Keyboard navigation support for accessibility and a smoother UX.&lt;br&gt;
    • 📸 Image hover reveals for historical documents and figures.&lt;br&gt;
    • 📦 Scroll-triggered animations to keep the experience lively and flowing.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/wWJytayLBjo"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;Although I’m proud of the final result, there’s always room to improve:&lt;br&gt;
    • 📈 Lighthouse Score: I’ve optimized most areas, but I’m aiming for a perfect 100.&lt;br&gt;
    • 📱 Mobile Responsiveness: With this much interactivity, a responsive mobile layout needs thoughtful re-architecture — I’m actively exploring this.&lt;/p&gt;

&lt;h2&gt;
  
  
  ❤️ Final Thoughts
&lt;/h2&gt;

&lt;p&gt;This project means more than just code. Juneteenth is a story of struggle and celebration, and I wanted to reflect that with carefully chosen visuals and deliberate design. It’s a tribute through UI, and I hope it both informs and inspires.&lt;/p&gt;

&lt;p&gt;Let me know your thoughts — feedback is welcome! 🙌&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>frontendchallenge</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>I built a WhatsApp Web UI Clone - Chats section</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Mon, 26 May 2025 18:13:15 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/i-built-a-whatsapp-web-ui-clone-2723</link>
      <guid>https://dev.to/soorajsnblaze333/i-built-a-whatsapp-web-ui-clone-2723</guid>
      <description>&lt;p&gt;🚀 Just Finished Building a WhatsApp UI Clone (Chats section) — Built with React &amp;amp; Dynamic Mock APIs!&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%2Fgu5epfw198ma8s8jogp9.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%2Fgu5epfw198ma8s8jogp9.png" alt="Image description" width="800" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Over the past few weeks, I’ve been working on a detailed frontend clone of WhatsApp Web — built entirely using React, Tailwind, and mocked API services. My goal was to recreate the real chat experience without storing any static UI data. Every message, contact, and interaction is dynamically fetched — making the app easily integratable with backends like Firebase, Supabase, or a custom Node API.&lt;/p&gt;

&lt;p&gt;Here are some highlights I’m proud of:&lt;br&gt;
✅ Dynamic routing and rendering of chat messages based on selected contact&lt;br&gt;
✅ Simulated “typing” indicator &amp;amp; new message injection for live UI testing&lt;br&gt;
✅ Reaction support with bounce + stagger animations (LTR or RTL depending on sender)&lt;br&gt;
✅ Modular state management using React Contexts (Chats, Contacts, Tabs, Profiles, etc.)&lt;br&gt;
✅ Fully responsive layout modeled after WhatsApp Web&lt;br&gt;
✅ Future-ready: Planning to implement IntersectionObserver to enable lazy loading older messages when scrolling to the top&lt;/p&gt;

&lt;p&gt;🔧 Built for scalability — the frontend is backend-agnostic and ready for real-time integrations&lt;/p&gt;

&lt;p&gt;Would love your feedback or suggestions! 🙌&lt;br&gt;
You can view the project source code here: &lt;a href="https://github.com/SoorajSNBlaze333/whatsapp-react-clone" rel="noopener noreferrer"&gt;https://github.com/SoorajSNBlaze333/whatsapp-react-clone&lt;/a&gt;&lt;br&gt;
Live App: &lt;a href="https://chat-react-clone.vercel.app" rel="noopener noreferrer"&gt;https://chat-react-clone.vercel.app&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>socialmedia</category>
    </item>
    <item>
      <title>🎬 I Built a YouTube Clone</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Tue, 13 May 2025 03:21:44 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/i-built-a-youtube-clone-f0a</link>
      <guid>https://dev.to/soorajsnblaze333/i-built-a-youtube-clone-f0a</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;React. TypeScript. Next.js. Tailwind. Framer Motion.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hey fellow devs! 👋&lt;/p&gt;

&lt;p&gt;I recently embarked on a wild ride: building a YouTube clone from scratch for my portfolio. Why? Because watching YouTube wasn’t enough. I wanted to become YouTube (minus the billion-dollar budget and the legal team).&lt;/p&gt;

&lt;p&gt;Here’s how I did it, what I learned, and how many times I yelled “why is this not working?!” into the void.&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%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExd3NkMXR1Y2pxZmZqOTFjYTBqZ2J0Zzg3bndkazBzN2h0dXNuZXZuOSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FS5E6VIkBAGujjfT0zz%2Fgiphy.gif" 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%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExd3NkMXR1Y2pxZmZqOTFjYTBqZ2J0Zzg3bndkazBzN2h0dXNuZXZuOSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FS5E6VIkBAGujjfT0zz%2Fgiphy.gif" width="480" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Github Repository - &lt;a href="https://github.com/SoorajSNBlaze333/youtube-video-view" rel="noopener noreferrer"&gt;https://github.com/SoorajSNBlaze333/youtube-video-view&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Live App - &lt;a href="https://y-video-clone-two.vercel.app" rel="noopener noreferrer"&gt;https://y-video-clone-two.vercel.app&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Week 1 - The “Optimism” Phase
&lt;/h2&gt;

&lt;p&gt;Ah, Week 1. Back when I thought this would be easy.&lt;/p&gt;

&lt;h3&gt;
  
  
  📝 Tech Stack I used:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;React (because I’m not a monster)&lt;/li&gt;
&lt;li&gt;TypeScript (because I love suffering with strict types)&lt;/li&gt;
&lt;li&gt;Next.js (SSR, baby!)&lt;/li&gt;
&lt;li&gt;Tailwind CSS (utility classes = sanity)&lt;/li&gt;
&lt;li&gt;Framer Motion (because even my modals deserve personality)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  💪🏻 What I tackled:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Creating a responsive layout.&lt;/li&gt;
&lt;li&gt;Main video feed and the different sections.&lt;/li&gt;
&lt;li&gt;Making it look vaguely like YouTube without getting sued.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🏆 Win of the week: Made my first video card component. It looked suspiciously good. I stared at it for 10 minutes like Michelangelo looking at David.&lt;/p&gt;

&lt;p&gt;💩 Fail of the week: I used div soup everywhere. Refactored it all the next day. RIP productivity.&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%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExNTFsdWxhcnJtdnhwY21pcGh4YncwdWkzMDc0cmZweWh6MzZxd2VmYSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F7lw1DMGuZREac%2Fgiphy.gif" 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%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExNTFsdWxhcnJtdnhwY21pcGh4YncwdWkzMDc0cmZweWh6MzZxd2VmYSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F7lw1DMGuZREac%2Fgiphy.gif" width="400" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎥 Week 2 – The “Feature Frenzy” Arc
&lt;/h2&gt;

&lt;p&gt;This is the week when I stopped thinking, “Maybe I’ll finish early,” and started thinking, “What have I done?”&lt;/p&gt;

&lt;h3&gt;
  
  
  🧱 What I built:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A complete backend (psst I just used Next's api mocks to simulate a backend that sends me all the info I need. You name it video data, channel data, shorts data and even the current video as a stream).&lt;/li&gt;
&lt;li&gt;The Shorts section – Yes, I cloned TikTok inside my YouTube clone. It scrolls vertically, it auto-plays, and it probably gives off Gen-Z energy.&lt;/li&gt;
&lt;li&gt;The video list section – Think “related videos,” “recommended,” and “clickbait paradise.”&lt;/li&gt;
&lt;li&gt;Video metadata display – Views, likes, channel name, upload date, and that dangerously addictive “Subscribe” button (which, spoiler alert, doesn’t do anything… yet).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎯 Win of the week:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I used Framer Motion to add slick transitions between sections.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  😵‍💫 Moment of pain:
&lt;/h3&gt;

&lt;p&gt;“Why is this video taking up 100% of the screen on mobile?”&lt;/p&gt;

&lt;p&gt;– Me, to no one, at 2AM&lt;/p&gt;

&lt;h2&gt;
  
  
  🧪 Week 3 – Polish, Deploy, and Full-On Control Freak
&lt;/h2&gt;

&lt;p&gt;This week, things got serious. Not only was I chasing pixel-perfection like a caffeine-powered UI goblin, but I also dove deep into custom media control territory.&lt;/p&gt;

&lt;h3&gt;
  
  
  🎮 What I built:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A full custom video player UI – Sure, I used ReactPlayer to handle video playback (because reinventing H.264 is not on my bucket list), but every single control — play/pause, volume, full screen, the scrubber/slider, and even the time duration display — was built from scratch.&lt;/li&gt;
&lt;li&gt;Yes, I coded the slider. Yes, it made me question my life choices. Yes, it looks amazing now.&lt;/li&gt;
&lt;li&gt;Responsive polish – No matter what screen size you throw at it, the layout now behaves like a disciplined flex-box ninja.&lt;/li&gt;
&lt;li&gt;Animations, again! – Subtle transitions for the player controls using Framer Motion. They fade in/out based on hover/focus. It’s like Netflix, but with more love and less licensing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🧯 Panic moments:
&lt;/h3&gt;

&lt;p&gt;“Why is my custom slider controlling the volume instead of the timeline?”&lt;/p&gt;

&lt;p&gt;– Me, after 30 minutes of fighting state like it owed me money&lt;/p&gt;

&lt;h3&gt;
  
  
  🎉 Deployed to Vercel:
&lt;/h3&gt;

&lt;p&gt;At the end of the week, I pushed everything to Vercel and just… stared at it. Not gonna lie, I hit play on my own video and watched it for 10 minutes like it was a Hollywood premiere.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 What I Learned (besides the limits of my sanity)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Next.js + Tailwind = 💖: I would swipe right on this combo any day.&lt;/li&gt;
&lt;li&gt;TypeScript saves you later, haunts you now. The autocomplete was amazing though.&lt;/li&gt;
&lt;li&gt;Animations make a huge difference. A 300ms transition can make your app feel chef-level.&lt;/li&gt;
&lt;li&gt;Mock data is your best friend. Until you replace it with real data and everything breaks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🎯 What’s Next?
&lt;/h2&gt;

&lt;p&gt;Maybe I’ll add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search functionality&lt;/li&gt;
&lt;li&gt;Real backend integration (Firebase? Supabase? Skynet?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or maybe I’ll just watch actual YouTube for a bit and chill.&lt;/p&gt;

&lt;p&gt;“Ever built a YouTube clone or something wildly overambitious just for fun? Tell me about it 👇”&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>socialmedia</category>
    </item>
    <item>
      <title>Personal Dev Portfolio</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Tue, 25 Mar 2025 14:24:49 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/personal-dev-portfolio-15h1</link>
      <guid>https://dev.to/soorajsnblaze333/personal-dev-portfolio-15h1</guid>
      <description>&lt;p&gt;Face it! Every one of us has started a portfolio or a side project and setup everything just to not touch it for the next couple of months.&lt;/p&gt;

&lt;p&gt;And then one day out of the blue, you remember that you had started this and get the fire in you started again to finish the project. And then you take a look at what you wrote and go&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%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExemEzMHVnZTY2bWUzY2N0bHc2dWdtOXRtdTB4aHNmNnRsdm82ems3ZCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FK7xnY73yraA5TNPVc1%2Fgiphy.gif" 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%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExemEzMHVnZTY2bWUzY2N0bHc2dWdtOXRtdTB4aHNmNnRsdm82ems3ZCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FK7xnY73yraA5TNPVc1%2Fgiphy.gif" width="382" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, I am no different, I started this project a year ago and completely forgot about it. My old portfolio was too outdated and contained broken links. So I decided that I was gonna change that. And as usual, I stopped after 3 days 😂. But I did not give this up, kept going at it again and again. &lt;/p&gt;

&lt;p&gt;And I finally made it!. I updated my dev portfolio 😂😂😂. &lt;/p&gt;

&lt;p&gt;This is the link to it &lt;a href="https://www.soorajsivadasannair.dev" rel="noopener noreferrer"&gt;https://www.soorajsivadasannair.dev&lt;/a&gt;. You guys can take a look at it and constructive feedback is more than appreciated.&lt;/p&gt;

&lt;p&gt;This is a post of all the developers who have started a project and have stopped it for personal reasons or just forgot about it. Keep going at it. One day you will finish it!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>CSS Art: June (The peaceful days)</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Mon, 10 Jun 2024 01:22:13 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/css-art-june-4hme</link>
      <guid>https://dev.to/soorajsnblaze333/css-art-june-4hme</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/frontend-2024-05-29"&gt;Frontend Challenge v24.04.17&lt;/a&gt;, CSS Art: June.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspiration
&lt;/h2&gt;

&lt;p&gt;Today I am posting a figment of my imagination in the form of the June CSS Challenge. Where I live, June means it's sunny, cloudy and raining at the same time. And where I live is green and full of trees and also has deer nearby. So I put them all together. Whenever I open my patio windows, I see something like this. This is what I tried to put in my CSS art. This is my inspiration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo (Please re-run the pen for the best results)
&lt;/h2&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/SoorajSnBlz/embed/RwmZxeW?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/SoorajSnBlz/pen/RwmZxeW" rel="noopener noreferrer"&gt;Here&lt;/a&gt; is the codepen link for the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Step 1: Where to start
&lt;/h2&gt;

&lt;p&gt;Figuring out what kind of a scene I was gonna create. This is one of the most hardest parts of the challenge, as if I choose something that would be too hard, I would lose interest and would give up. It had to be something that I see every day and I love seeing so that I would finish it no matter what. That is why I chose this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: What are all the main parts
&lt;/h2&gt;

&lt;p&gt;Now let's figure out what all will make up the scene. Like I mentioned it's hot, its cloudy, so we need the Sun and some clouds. Next I mentioned it's green and full of trees, so we also need green meadows and a few trees. Next I mentioned deer, since I cannot add a whole bunch of deer, I represent all of them together as one single deer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Putting all the parts together
&lt;/h2&gt;

&lt;p&gt;Now that we have all the parts, we start off creating each part separately, I started off with the sky, with the Sun in the middle of the sky and some static clouds. Wait! clouds move don't they, so I added some keyframes for the clouds to move like they do in the sky.&lt;br&gt;
Next up would be some green meadows. I took some inspiration off of google by searching for some low poly images for a summer scene and I remembered the windows wallpaper we all used to see.&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%2Fr37wwt0xcusywuutjqjv.jpg" 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%2Fr37wwt0xcusywuutjqjv.jpg" alt="meadows" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So after I added those cute little meadows, let's add some trees on each of them. Now let's add the main character, our deer.&lt;/p&gt;

&lt;p&gt;The deer was the part that took the most time to create as it has a lot of elements on it. The body, neck, head, ears, tail, front legs, hind thighs, legs, antlers aaaah!, so many parts. Let's start from the body. I created the deer based off a few google results like "low poly deer"&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%2Frdgrb4h79rsmkv91r08u.jpg" 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%2Frdgrb4h79rsmkv91r08u.jpg" alt="Low poly deer" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the deer was painstakingly created, I couldn't just leave it static. I had to give it some life, so I animated the deer bending its neck to eat some grass, its tail and ears twitching also.&lt;/p&gt;

&lt;p&gt;Finally it was to put everything together as I had envisioned in my mind. When I open my patio window I see this image, so I made an opening window out of the screen.&lt;/p&gt;

&lt;p&gt;This is my first css challenge not following some of the conventional UI design and development techniques. I thank dev.to for providing this opportunity to explore and showcase my creativity.&lt;/p&gt;

</description>
      <category>frontendchallenge</category>
      <category>devchallenge</category>
      <category>css</category>
    </item>
    <item>
      <title>Queuing Rest Apis using JavaScript</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Mon, 10 Apr 2023 16:46:24 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/queuing-api-25oa</link>
      <guid>https://dev.to/soorajsnblaze333/queuing-api-25oa</guid>
      <description>&lt;p&gt;Many of us web developers, frontend developers, fullstack developers have been using REST apis for ages. I am also one of these developers who constantly uses rest apis for my web apps. But whenever I used them, I would often wish that the library I choose would have an inbuilt Queue in them to handle requests, keep them stored in case of a network issue or something else, resume the handling of the request once the internet is running again all while handling 1 request at a time to avoid any inconsistencies with data. &lt;/p&gt;

&lt;p&gt;Just to make things clear, I am not the most perfect developer so I do make mistakes quite often. That is where I would need you guys' help. I have come up with a small wrapper Class and function around the http library that I often use (axios) to implement a queuing system. It is not the best solution yet, but with some changes and good optimization it could be.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;As you can see above, I have made things fairly simple by creating an &lt;code&gt;API&lt;/code&gt; class that handles the request in a generic format and then I have created a function called &lt;code&gt;queuedAPI&lt;/code&gt; that will expose the api methods of the &lt;code&gt;API&lt;/code&gt; Class and queue them into the queue. Once it is added to queue, the requests are dequeued in the order in which they were added to the queue. I am also making sure to see if the client has a navigator object and if we are connected to internet before dequeuing the promise. If we are not connected to the internet, we will keep looking until the browser gets a connection to the internet. I know this is performance intensive, but I am trying to write an observer or find different ways to limit the number of retries. One way could be to use a limit variable like &lt;code&gt;RETRY_LIMIT = 5&lt;/code&gt; or something like that.&lt;/p&gt;

&lt;p&gt;Another idea that I have is to store the queue in the local storage of the browser. This is because if the internet is lost and the user refreshes the page, then the queue would become empty. If I were to store the queue in the local storage then I would be able to access it on the page load and dequeue the existing queue requests that was done before the page refresh. But that would also mean that I would have to find a way to not store any sensitive information that would be passed in the api such as password info or payment info. So I would have to avoid those apis and provide an option in the api if the developer would like that api to be stored in a temp storage or not.&lt;/p&gt;

&lt;p&gt;Lastly I would like to add a priority to each queue item, so that the queue is dequeued with priority in mind. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;App.jsx&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./components/Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./libs/api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCounter&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;apiData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setApiData&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;online&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setOnline&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onLine&lt;/span&gt;&lt;span class="o"&gt;??&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;get&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currentQueue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;post&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://62baf8ff573ca8f8328ff37d.mockapi.io/api/v1/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setApiData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setOnline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onLine&lt;/span&gt;&lt;span class="o"&gt;??&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;renderNetworkStatus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;online&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flex justify-center items-center border-2 border-green-500 bg-green-50 rounded-full px-2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-2 w-2 bg-green-500 rounded-full mr-1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-green-500 text-xs font-semibold mb-[0.5px]&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;online&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flex justify-center items-center border-2 border-red-500 bg-red-50 rounded-full px-2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-2 w-2 bg-red-400 rounded-full mr-1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-red-500 text-xs font-semibold mb-[0.5px]&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;offline&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-full w-full flex justify-center items-center flex-col&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-3xl my-2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Requests&lt;/span&gt; &lt;span class="nx"&gt;Left&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="na"&gt;Queue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;section&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flex justify-center align-center gap-2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;get&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Make&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;post&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Make&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/section&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-xs overflow-y-auto max-h-[400px] p-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;apiData&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;absolute bottom-3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;renderNetworkStatus&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/xxYzric89bo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I'm also adding a small video clip of the queue when we request apis but not connected to the internet and then how the apis execute in order when we are connected again.&lt;/p&gt;

&lt;p&gt;If you guys feel that there is any kind of optimization or refactoring that can be made to make this even better or faster, please let me know in the comments. &lt;/p&gt;

&lt;p&gt;And if you do like this idea please star this gist that contains the code for the queue API&lt;br&gt;
&lt;a href="https://gist.github.com/SoorajSNBlaze333/e6cd7d3103272af7298b4414cd19b024" rel="noopener noreferrer"&gt;https://gist.github.com/SoorajSNBlaze333/e6cd7d3103272af7298b4414cd19b024&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Simple Javascript Modules - Local Storage Module</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Sat, 26 Jun 2021 13:50:40 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/simple-javascript-modules-local-storage-module-567p</link>
      <guid>https://dev.to/soorajsnblaze333/simple-javascript-modules-local-storage-module-567p</guid>
      <description>&lt;p&gt;Working as a web developer I work on the client side dealing with lots of continuous data from the server. All though it is a good practice to not store data on the client side, there will be many cases where we want to store some information on the client for faster access. A good use case would be the app theme &lt;code&gt;theme: "light"&lt;/code&gt; or &lt;code&gt;theme: "dark"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So that is where we can use Local Storage of the Browser using the &lt;code&gt;window.localStorage API&lt;/code&gt;. It is a free storage space available for almost all major browsers and we can save a considerable amount of safe data for quick use in our application. It can be found on almost all major browsers. You can view, modify or delete the local storage data under the Application Tab in your browser followed by Local Storage and clicking your domain.&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%2Fadvorhz4c96b4nvl3qb5.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%2Fadvorhz4c96b4nvl3qb5.png" alt="Local Storage Description" width="762" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see here in the code below, I have added all the things that we mostly do with local storage. Usually all these functions are separately written in a utility module. But here I have kept it separately so that in any case of change, we just replace the functions inside the module and our application code remains untouched. &lt;code&gt;The whole point of writing these functions together as a module is to keep the code clean, crisp and understandable.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// A localStorage object for performing crud operations on window.localStorage with ease&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Storage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// check if local storage is supported on browser&lt;/span&gt;
  &lt;span class="na"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;localStorage&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;span class="c1"&gt;// get the local storage data of the key&lt;/span&gt;
  &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// add a new data to given key in local storage&lt;/span&gt;
  &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// remove the data by the given key from local storage&lt;/span&gt;
  &lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// wipe entire local storage of current domain&lt;/span&gt;
  &lt;span class="nf"&gt;wipe&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Storage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have written a total of 5 properties on my module here which will use the &lt;code&gt;window.localStorage API&lt;/code&gt; and are as follows.&lt;/p&gt;

&lt;p&gt;1.&lt;code&gt;exists&lt;/code&gt; - This contains a boolean value that checks if the current browser supports local storage or not.&lt;/p&gt;

&lt;p&gt;2.&lt;code&gt;get(key)&lt;/code&gt; - This function is used to get the data that is associated with the key that is sent in the parameters. For example if &lt;code&gt;get("name")&lt;/code&gt; will get you the data that is saved under the name key in local storage. This function calls the window function called &lt;code&gt;localStorage.getItem()&lt;/code&gt; which takes 1 parameter "key".&lt;/p&gt;

&lt;p&gt;3.&lt;code&gt;add(key, data)&lt;/code&gt; - This function is used to add new data to the local storage. The &lt;code&gt;key&lt;/code&gt; attribute specifies to which key the data should be added to and the &lt;code&gt;data&lt;/code&gt; attribute contains the data to be added. This function calls the window function called &lt;code&gt;localStorage.setItem()&lt;/code&gt; which takes 2 parameters "key" and "data". It could be anything like a string, number, array, object etc.&lt;/p&gt;

&lt;p&gt;For example running this =&amp;gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Storage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;myKey&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sooraj&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Will add this under the key called "myKey"&lt;br&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%2F6r9tubucxgkzrgtjjaxv.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%2F6r9tubucxgkzrgtjjaxv.png" alt="Added Local Storage" width="762" height="749"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4.&lt;code&gt;remove(key)&lt;/code&gt; - This function is used to remove the data associated with the key that is sent in the parameters. This function calls the window function called &lt;code&gt;localStorage.removeItem()&lt;/code&gt; which takes 1 parameter "key". If &lt;code&gt;remove("myKey")&lt;/code&gt; is called the data that was added before would be cleared from the storage.&lt;/p&gt;

&lt;p&gt;5.&lt;code&gt;wipe()&lt;/code&gt; - This is a method I would not use that many times. This function calls the window function called &lt;code&gt;localStorage.clear()&lt;/code&gt; which takes no parameters. This function clears all the local storage data associated with the client on that domain.&lt;/p&gt;

&lt;p&gt;Well, this is my Storage module. Hope you guys found it useful. Go ahead and try it out...&lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Space Physics</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Sun, 30 May 2021 07:46:45 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/space-physics-m9d</link>
      <guid>https://dev.to/soorajsnblaze333/space-physics-m9d</guid>
      <description>&lt;p&gt;So last month I was bored and decided to have some fun by coding some space related stuff. I took 5 space related topics but I have added 2 of them here since the rest are still in work in progress. I have been so much in to Space and Astronomy recently and then I wrote this simply to understand what happens and how it happens. These are my codepens&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How a satellite/asteroid/comet changes it speed and trajectory using the help of a planet or any other object with a gravitational force.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/SoorajSnBlz/embed/QWpOGvq?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Saturn's rings using real gravitational physics. The rings are actually small particles moving at high speed held together by the gravitational force but I keep the trails to look like there are more particles there. There are lots of properties to adjust on the codepen. Feel free to check it out.&lt;/li&gt;
&lt;/ol&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%2Flogfiz1n1f4z32zyy0xh.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%2Flogfiz1n1f4z32zyy0xh.png" alt="Alt Text" width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code is a little unoptimized for now so I am not adding the codepen embed here but here is the link to check it out &lt;a href="https://codepen.io/SoorajSnBlz/pen/Vwprmdv" rel="noopener noreferrer"&gt;https://codepen.io/SoorajSnBlz/pen/Vwprmdv&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>canvas</category>
      <category>physics</category>
      <category>math</category>
    </item>
    <item>
      <title>Animated Buttons using Javascript (GSAP) - 1</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Wed, 25 Nov 2020 07:28:17 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/animated-buttons-using-javascript-gsap-1-23d</link>
      <guid>https://dev.to/soorajsnblaze333/animated-buttons-using-javascript-gsap-1-23d</guid>
      <description>&lt;p&gt;Hey there guys,&lt;br&gt;
     Here is a small animation ripple effect I created using &lt;a href="https://greensock.com/" rel="noopener noreferrer"&gt;gsap&lt;/a&gt;. I created this using just an event listener and a &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; tag along with the &lt;code&gt;gsap fromTo() method&lt;/code&gt;. This is just one of the cool animations you can create. &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/SoorajSnBlz/embed/ExgYwEb?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Furthermore, you can stagger up your animations by using the &lt;code&gt;stagger&lt;/code&gt; property. Stagger will basically run your animations which come under the same property, for example multiple ripples, to run sequentially with a small delay in between them, like this.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/SoorajSnBlz/embed/rNMBYJq?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>showdev</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>Web-App using HTML, JS &amp; Firebase - Part 2</title>
      <dc:creator>Sooraj (PS)</dc:creator>
      <pubDate>Tue, 10 Nov 2020 04:03:35 +0000</pubDate>
      <link>https://dev.to/soorajsnblaze333/web-app-using-html-js-firebase-part-2-439p</link>
      <guid>https://dev.to/soorajsnblaze333/web-app-using-html-js-firebase-part-2-439p</guid>
      <description>&lt;p&gt;Now that we have covered the basics of &lt;a href="https://www.skcript.com/svr/web-app-using-html-js-firebase-part-1/" rel="noopener noreferrer"&gt;Firebase using a simple HTML &amp;amp; JS form&lt;/a&gt;, Let us move to the next steps. In this part we will be seeing how to connect Cloud Firestore to the UI in real time and make real time changes in the client.&lt;/p&gt;

&lt;p&gt;To start off with the real time connection, we will &lt;strong&gt;reuse our old project&lt;/strong&gt; &lt;strong&gt;that we had created in the&lt;/strong&gt; &lt;a href="https://www.skcript.com/svr/web-app-using-html-js-firebase-part-1/" rel="noopener noreferrer"&gt;&lt;strong&gt;part 1&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;of this series&lt;/strong&gt;. For this we will be creating a live feed section like Twitch Chat. We will be using Cloud Firestore’s real time methods to update all the changes across all the clients that are connected to the feed keeping them in sync.&lt;/p&gt;

&lt;p&gt;Let’s start off by creating a new &lt;strong&gt;index.html&lt;/strong&gt; file under the public directory. We will rename our old index.html file and keep it there just in case we need it for reference. First we will create a new collection in our database called &lt;strong&gt;feeds&lt;/strong&gt;. This collection will have a document for each feed message that is created.&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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage6-20.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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage6-20.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let’s render our feeds collection using cloud firestore. Normally, we will just use the &lt;strong&gt;get()&lt;/strong&gt; method right? This time we will go for something called &lt;a href="https://firebase.google.com/docs/firestore/query-data/listen#listen_to_multiple_documents_in_a_collection" rel="noopener noreferrer"&gt;&lt;strong&gt;onSnapshot()&lt;/strong&gt;&lt;/a&gt;. Let’s write that inside our script tag. First let’s log our data, then we will display the result as HTML.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// variables&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;firebaseConfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// your config&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;initializeApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;firebaseConfig&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;firestore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;firestore&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// firebase functions&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;listFeeds&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;firestore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;feeds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;onSnapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;querySnapshot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;feeds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="nx"&gt;querySnapshot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;feeds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;feeds&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;listFeeds&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cloud Firestore has a method called &lt;strong&gt;onSnapshot&lt;/strong&gt; that is triggered every time the collection changes. This method can also be used on a document to detect the document change. The method provides you with a callback function with the querySnapshot of all the documents in the collection at that point of time.&lt;/p&gt;

&lt;p&gt;Then, we need to loop through each snapshot in the &lt;em&gt;querySnapshot&lt;/em&gt; to extract our document data. You can log the &lt;strong&gt;doc&lt;/strong&gt; object in the loop to check for all the possible types of data you can use to your needs.&lt;/p&gt;

&lt;p&gt;In this example, I will be using the &lt;strong&gt;id&lt;/strong&gt; key which holds the document id and the &lt;strong&gt;data()&lt;/strong&gt; to get the body of the document. Let’s run the HTML file and check for our log.&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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage9-8.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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage9-8.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And there you go, we have our first message loaded in the log. Now let’s try updating our collection using the Firestore Console and see if it triggers on the client side without refreshing the client.&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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage1-50.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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage1-50.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After updating the feeds collection you can now see that a new log has been created and the new list is shown here. Now we will use this to list our feed. We will just list our feed using a &lt;strong&gt;li&lt;/strong&gt; tag and some simple bootstrap styles.&lt;/p&gt;

&lt;p&gt;First we will create a &lt;strong&gt;ul&lt;/strong&gt; tag with the ID &lt;strong&gt;feeds,&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"feeds"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-group list-group-flush"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now, let’s modify our &lt;strong&gt;listFeeds()&lt;/strong&gt; function to something like this. This will indeed cause a problem (for every fetch we will get a history of data, so the IDs will be duplicated in listFeeds()) but for now we will see what we get.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;listFeeds&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;firestore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;feeds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;onSnapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;querySnapshot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;querySnapshot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;feed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;li&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;class&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;list-group-item&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;feeds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make life easier let’s create a simple form that will add a new feed on submission. We will use the &lt;strong&gt;add()&lt;/strong&gt; method of Firestore once again to add a new document to the collection. Let’s add something like this,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"feeds"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-group list-group-flush"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;onsubmit=&lt;/span&gt;&lt;span class="s"&gt;"return handleSubmit(event)"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"d-flex align-items-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"form-control"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt; &lt;span class="na"&gt;aria-describedby=&lt;/span&gt;&lt;span class="s"&gt;"emailHelp"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Type your message here"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-primary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Post&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And inside our script tag, let’s add,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;message&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;firestore&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;feeds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s try it now,&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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage3-8.gif" 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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage3-8.gif" width="800" height="400"&gt;&lt;/a&gt;&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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage5-4.gif" 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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage5-4.gif" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As expected, we will get all the array objects again which will push all the existing objects to the HTML once again. We can fix this by clearing the list before a fetch, but instead let’s use the &lt;strong&gt;docChanges()&lt;/strong&gt; method of querySnapshot to get only the updated data. Let’s modify our code then,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;listFeeds&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;firestore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;feeds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;onSnapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;querySnapshot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;querySnapshot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;docChanges&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;change&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;change&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;added&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;New city: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;change&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;change&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;modified&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Modified city: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;change&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;change&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;removed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Removed city: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;change&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now this method will only give us the documents that are added. So initially when the page is loaded, we will receive all the existing documents, and whenever a new document is added, only that document will be sent to us in the &lt;strong&gt;docChanges()&lt;/strong&gt; method.&lt;/p&gt;

&lt;p&gt;This will also make it easier to handle each type of change as we know that only that particular decisional branch will be taken. Let’s now update our added branch to something like this,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleNewFeed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;feed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;li&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;class&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;list-group-item&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;feeds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;prepend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// firebase functions&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;listFeeds&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;firestore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;feeds&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;onSnapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;querySnapshot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;querySnapshot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;docChanges&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;change&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;change&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;added&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;handleNewFeed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;change&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;change&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;modified&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Modified city: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;change&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;change&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;removed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Removed city: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;change&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;listFeeds&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s take a look at it now,&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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage2-4.gif" 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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage2-4.gif" width="800" height="400"&gt;&lt;/a&gt;&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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage4-2.gif" 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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage4-2.gif" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cool it works!!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Cool, our code is now working. Let’s just add some small designs to our code and make it look like a chat. We will open it on multiple tabs or windows and check if the message is reflecting across all tabs.&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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage8-2.gif" 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%2Fwww.skcript.com%2Fsvrmedia%2Fheroes%2Fimage8-2.gif" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that’s it! Experiment further with all the code, like the update and delete options in the &lt;strong&gt;querySnapshot()&lt;/strong&gt;. In the upcoming part we will discuss building &lt;strong&gt;REST APIs&lt;/strong&gt; using Firebase Cloud functions.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>html</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
