<?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: smrifat1411</title>
    <description>The latest articles on DEV Community by smrifat1411 (@smrifat1411).</description>
    <link>https://dev.to/smrifat1411</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F906890%2Fb3d63c92-e659-4139-833b-7dbb6d15464b.png</url>
      <title>DEV Community: smrifat1411</title>
      <link>https://dev.to/smrifat1411</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/smrifat1411"/>
    <language>en</language>
    <item>
      <title>What Word actually puts on your clipboard</title>
      <dc:creator>smrifat1411</dc:creator>
      <pubDate>Sat, 15 Aug 2026 20:12:52 +0000</pubDate>
      <link>https://dev.to/smrifat1411/what-word-actually-puts-on-your-clipboard-kgk</link>
      <guid>https://dev.to/smrifat1411/what-word-actually-puts-on-your-clipboard-kgk</guid>
      <description>&lt;p&gt;I was building an exam authoring tool. Teachers wrote their questions in Word — full of maths — and pasted them into the browser.&lt;/p&gt;

&lt;p&gt;The equations came through as pictures. Flat images of what used to be an equation. Nobody could click into one to fix a typo in a denominator; the only option was to delete it and rebuild the whole thing by hand.&lt;/p&gt;

&lt;p&gt;I assumed that would take an afternoon to fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  The thing I got wrong first
&lt;/h2&gt;

&lt;p&gt;My first instinct was the obvious one. Word pastes garbage, so strip the garbage. Kill the &lt;code&gt;mso-&lt;/code&gt; styles, kill the XML namespaces, kill the classes, keep the plain tags underneath.&lt;/p&gt;

&lt;p&gt;That works. The output is clean. It is also how you throw away the two most valuable things Word gave you.&lt;/p&gt;

&lt;p&gt;Because Word does not just send a mess. It sends a mess &lt;em&gt;with the good stuff buried in it&lt;/em&gt;, and the naive clean deletes the good stuff along with the noise.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is actually on your clipboard
&lt;/h2&gt;

&lt;p&gt;Copy something out of Word and you do not get a fragment. You get an entire HTML document, and it announces itself in the first line:&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;html&lt;/span&gt; &lt;span class="na"&gt;xmlns:o=&lt;/span&gt;&lt;span class="s"&gt;"urn:schemas-microsoft-com:office:office"&lt;/span&gt;
      &lt;span class="na"&gt;xmlns:w=&lt;/span&gt;&lt;span class="s"&gt;"urn:schemas-microsoft-com:office:word"&lt;/span&gt;
      &lt;span class="na"&gt;xmlns:m=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.openxmlformats.org/officeDocument/2006/math"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That third namespace is the one that matters. &lt;code&gt;xmlns:m&lt;/code&gt; is the maths namespace, and it is there because Word puts equations on the clipboard as OMML — Office Math Markup Language. The same structured maths that lives inside a &lt;code&gt;.docx&lt;/code&gt;. Not a picture. The real thing.&lt;/p&gt;

&lt;p&gt;Word &lt;em&gt;also&lt;/em&gt; puts a rasterized picture of the equation on the clipboard, tucked inside a conditional comment as a fallback for anything that cannot do better.&lt;/p&gt;

&lt;p&gt;So the equation is there twice. Once as an image. Once as actual maths.&lt;/p&gt;

&lt;p&gt;And here is the annoying part: the image is a plain &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;, so it survives naive cleaning without a scratch. The OMML is a namespaced element, so it gets swept out with all the other Word noise.&lt;/p&gt;

&lt;p&gt;Every paste handler I looked at keeps the picture and deletes the maths. Mine did too. That was the whole bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  Then I found the lists
&lt;/h2&gt;

&lt;p&gt;I fixed the equations, felt good about myself for roughly a day, and then someone pasted a numbered list.&lt;/p&gt;

&lt;p&gt;Word does not paste a list as a list. There is no &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;. There is no &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;. Every single item is a paragraph:&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;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;MsoListParagraphCxSpFirst&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;'mso-list:l0 level1 lfo1'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;![&lt;/span&gt;&lt;span class="na"&gt;if&lt;/span&gt; &lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="na"&gt;supportLists&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;'mso-list:Ignore'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;1.&lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;'font:7.0pt'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;span class="ni"&gt;&amp;amp;nbsp;&amp;amp;nbsp;&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;![&lt;/span&gt;&lt;span class="na"&gt;endif&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  First item
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I stared at this for a while before it clicked.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mso-list:l0 level1 lfo1&lt;/code&gt; is the only thing on the entire clipboard that says this paragraph belongs to a list. &lt;code&gt;l0&lt;/code&gt; is which list. &lt;code&gt;level1&lt;/code&gt; is how deep it is nested. That is your entire structure, living in a CSS property.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;1.&lt;/code&gt; is not a marker the browser draws. It is &lt;strong&gt;literal text&lt;/strong&gt;. An actual character sitting in the paragraph.&lt;/p&gt;

&lt;p&gt;Which means if you strip the styling and keep the text — the obvious thing to do — you get a paragraph with a number welded onto the front of it. It looks fine. Then the user inserts a new second item and gets 1, 1, 2, 3, and nothing renumbers, because nothing is numbering anything. It is not a list. It is five paragraphs wearing a list costume.&lt;/p&gt;

&lt;p&gt;And the span holding that number is labelled &lt;code&gt;mso-list:Ignore&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Word is telling you. Right there in the markup. &lt;em&gt;This is presentation, not content, please do not treat it as text.&lt;/em&gt; And every naive cleaner treats it as text.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bug that took me longest
&lt;/h2&gt;

&lt;p&gt;Here is the one I actually want to write down, because it cost me an evening and it fails in the worst possible way.&lt;/p&gt;

&lt;p&gt;I had a pipeline. Convert the maths, strip the conditional comments, strip the styles, done. Sensible order. Each step obviously correct.&lt;/p&gt;

&lt;p&gt;The problem is step two. Word wraps those list markers in a conditional comment, and I was deleting every conditional comment I found, because the equation image fallbacks live in conditional comments too and I wanted those gone.&lt;/p&gt;

&lt;p&gt;So by the time I got around to thinking about lists, the evidence was already in the bin. The &lt;code&gt;mso-list&lt;/code&gt; styles were still there, but the markers — the only record of whether the list was numbered or bulleted, and where it started — were gone.&lt;/p&gt;

&lt;p&gt;The correct order turns out to be:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Convert the maths first&lt;/strong&gt;, on the raw string. The HTML parser lowercases tag names, which quietly breaks anything looking for &lt;code&gt;&amp;lt;m:oMath&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not nuke every conditional comment.&lt;/strong&gt; Unwrap the list ones, delete the image ones.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rebuild the lists&lt;/strong&gt; — group paragraphs by list id, nest by level, read each marker, then drop the marker spans.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Now&lt;/strong&gt; strip the styling. The structure is safe, so the &lt;code&gt;mso-&lt;/code&gt; stuff carries no information any more.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Clean before you reconstruct and step four eats what step three needed.&lt;/p&gt;

&lt;p&gt;What makes this genuinely nasty is that it does not throw. You do not get an error. You get clean, valid, perfectly reasonable HTML. It is just the wrong shape, and you will not find out until a user complains that their list will not renumber.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three traps in the markers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;That &lt;code&gt;o&lt;/code&gt; is not the letter o.&lt;/strong&gt; Word's second-level bullet is a hollow circle drawn in Courier New, and it comes through as the character &lt;code&gt;o&lt;/code&gt;. Treat markers as ordinals and your bulleted list comes back with stray o's scattered through it. The reliable test is punctuation — ordered markers always end in &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;)&lt;/code&gt;, bullets never do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;i.&lt;/code&gt; is ambiguous, &lt;code&gt;i. ii. iii.&lt;/code&gt; is not.&lt;/strong&gt; A list starting with &lt;code&gt;i.&lt;/code&gt; could be roman numerals or the ninth letter of the alphabet. One marker cannot tell you. The run can. So read the whole sequence before you decide the list type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are two kinds of conditional comment&lt;/strong&gt;, and they are not the same thing:&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="c"&gt;&amp;lt;!--[if gte mso 9]&amp;gt;  ...  &amp;lt;![endif]--&amp;gt;&lt;/span&gt;   downlevel-hidden — a real comment
&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;![&lt;/span&gt;&lt;span class="na"&gt;if&lt;/span&gt; &lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="na"&gt;supportLists&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; ...  &lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;![&lt;/span&gt;&lt;span class="na"&gt;endif&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;     downlevel-revealed — content is live
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second one has no &lt;code&gt;--&lt;/code&gt;. Its contents are meant to be displayed. Browsers parse it as a bogus comment, so you have to unwrap it as a string before the DOM ever sees it. One missing pair of hyphens is the difference between keeping your list structure and losing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before and after
&lt;/h2&gt;

&lt;p&gt;Naive cleaning:&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;p&amp;gt;&amp;lt;span&amp;gt;&lt;/span&gt;1.&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;First&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;span&amp;gt;&lt;/span&gt;a.&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;Nested&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;span&amp;gt;&lt;/span&gt;2.&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;Second&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reading the markers first:&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;ol&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;First
    &lt;span class="nt"&gt;&amp;lt;ol&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"a"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;li&amp;gt;&lt;/span&gt;Nested&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Second&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ol&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first one looks clean. It is permanently broken. The second one is a list again, and the browser owns the numbering.&lt;/p&gt;

&lt;h2&gt;
  
  
  I put it in a package
&lt;/h2&gt;

&lt;p&gt;The afternoon turned into rather more than an afternoon, so I pulled it out of the exam builder and published it: &lt;strong&gt;&lt;a href="https://github.com/smrifat1411/wordpaste" rel="noopener noreferrer"&gt;wordpaste&lt;/a&gt;&lt;/strong&gt;. MIT, zero dependencies, about 3.5 kB gzipped.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;wordpaste
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One function in, clean HTML out:&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;transformPastedHTML&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="s1"&gt;wordpaste&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Editor&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;extensions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;StarterKit&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;editorProps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;transformPastedHTML&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;That is Tiptap. ProseMirror takes the same prop because Tiptap is built on it. Lexical needs you to claim the paste command, and plain &lt;code&gt;contenteditable&lt;/code&gt; takes about three lines. It also handles LibreOffice, Outlook, Excel and Google Docs, and leaves ordinary HTML alone.&lt;/p&gt;

&lt;p&gt;If you would rather not take a dependency, honestly, fine — the ordering is the part worth stealing. &lt;strong&gt;Read the markers, rebuild, then clean.&lt;/strong&gt; That is the whole insight, and it is about forty lines of work.&lt;/p&gt;

&lt;p&gt;You can &lt;a href="https://smrifat1411.github.io/wordpaste/" rel="noopener noreferrer"&gt;paste one of your own documents into the playground&lt;/a&gt; and see what your clipboard is really carrying. It runs entirely in your browser, nothing gets uploaded. I would recommend trying it with a document that has equations in it. It is a bit horrifying.&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>software</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Exploring RxDB: The Concepts It Holds</title>
      <dc:creator>smrifat1411</dc:creator>
      <pubDate>Sun, 20 Aug 2023 00:36:33 +0000</pubDate>
      <link>https://dev.to/smrifat1411/exploring-rxdb-friend-of-a-js-developer-2oh0</link>
      <guid>https://dev.to/smrifat1411/exploring-rxdb-friend-of-a-js-developer-2oh0</guid>
      <description>&lt;p&gt;Hello there! Today, we're diving into the exciting world of RxDB – a modern database technology that works like an essential collaborator of web apps. With features like real-time updates and offline use, RxDB makes sure your app's stays working, fresh even without internet. It seamless integration with JavaScript enable you to mastering it with your JS skill. Curious to know more about this cool database tech? Let's explore together!&lt;/p&gt;

&lt;h4&gt;
  
  
  Table of Contents:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;What is RxDB&lt;/li&gt;
&lt;li&gt;
RxDB's nucleus

&lt;ul&gt;
&lt;li&gt;Reactive Programming&lt;/li&gt;
&lt;li&gt;Offline-First&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Real-Time and Offline Efficiency in Web Apps&lt;/li&gt;
&lt;li&gt;Key-Features&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What is Rxdb?
&lt;/h2&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first line I would like to say RxDB, short for Reactive Database. Keep in mind "&lt;strong&gt;Reactive&lt;/strong&gt;", we will talk more and more about this later. RxDB  is a NoSQL database designed as a &lt;strong&gt;JavaScript library&lt;/strong&gt; for efficient data storage and management in web applications.This means, RxDB is not just a &lt;em&gt;standalone database&lt;/em&gt; like MongoDB or traditional SQL databases; rather, it's a &lt;em&gt;library&lt;/em&gt; that enables developers to work with a NoSQL database called IndexedDB using JavaScript directly in their web applications. Basically it wrapped IndexedDB or WebSQL or any other supported browser database with a layer of extra functionality.&lt;/p&gt;

&lt;p&gt;I am clearing more it, Databases like MongoDB (a NoSQL database), IndexedDB, or traditional SQL databases (such as MySQL or PostgreSQL) aren't initially structured as JavaScript libraries. Although they can use within JavaScript applications, they need additional drivers, libraries, or middleware for efficient interaction through JavaScript.&lt;/p&gt;

&lt;p&gt;This contrast is where RxDB excels. Built upon familiar web technologies like IndexedDB and WebSockets, RxDB easily integrates with JavaScript. Developers can interact with and manage data using their existing JavaScript skills. Unlike the extra setup required by other databases, RxDB easily integratable with JavaScript, allowing direct utilization in web applications without the need for external connectors or drivers. This frequent integration ensures a friendly experience, simplifying data storage and management within JavaScript-based web applications. &lt;br&gt;
RxDB is designed to provide a more reactive and user-friendly interface for developers.&lt;/p&gt;

&lt;p&gt;It leverages the capabilities of IndexedDB database for data storage but also offers features like real-time data synchronization, query optimization, and a more streamable API. &lt;/p&gt;

&lt;p&gt;I am sure you are definitely not satisfy with this little explanation, please see their well arranged &lt;a href="https://rxdb.info/"&gt;doc&lt;/a&gt; for get a complete overview.&lt;/p&gt;
&lt;h2&gt;
  
  
  RxDB's Nucleus: &lt;a&gt;
&lt;/a&gt;
&lt;/h2&gt;


&lt;h4&gt;
  
  
  Reactive Programming: &lt;a&gt;
&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Let's talk about something seriously cool –  When you chatted with your friend through whatsapp or any other messaging app and as your friend types, you see their messages pop up in real-time.That's the heartbeat of reactive programming – your app reacts to changes as if it's part of the chat who knows he has to show the updated message to your app screen, when your friend send a new message.&lt;/p&gt;

&lt;p&gt;let, clear it more...Suppose you're watching a live event streaming on youtube. As people comment, their thoughts pop up in real-time, creating a dynamic conversation. This is the essence of reactive programming – where apps react to changes as they happen, just like the comments appearing as people post them.&lt;/p&gt;

&lt;p&gt;Now, here RxDB comes to play. Imagine you and your team are all working on a shared document. As someone modifies a sentence or adds a new idea, guess what? Those changes instantly pop up on your screen, without any annoying refresh or reload. It's like having a co-author right there beside you, keeping your document updated in real-time. Thanks to reactive programming and RxDB, your app stays in tune and updated with these changes.&lt;br&gt;
&lt;/p&gt;

&lt;h4&gt;
  
  
  Offline-First:  &lt;a&gt;
&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Can you recall the moment when Wi-Fi decides to go on a break. or suddenly you move to a 2g coverage area. That's where the "offline-first approach" swoops in to save the day.&lt;/p&gt;

&lt;p&gt;Think of it like you are carrying a unbelievable modern app on your Ipad that lets you note down creative ideas,updating tasks, important meetings and keep working even without Wi-Fi. It's your way of staying productive, regardless of the connection's mood swings. And guess what? When the Wi-Fi fairy returns, here comes RxDB, our app's personal hero,personal friend. It quietly syncs everything up behind the scenes – no fuss, no hassle. It's like having your own data butler, making sure everything's in perfect harmony. With RxDB on your side, you and your app are always on the same track same beat, even when the internet doesn't act friendly.&lt;/p&gt;



&lt;h2&gt;
  
  
  Importance of Real-Time ,Offline Efficiency in Web Apps:&lt;a&gt;
&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Assume that you are creating a fantastic  online store using React. Let's talk about &lt;strong&gt;real-time updates&lt;/strong&gt; and &lt;strong&gt;offline functionality&lt;/strong&gt; – they're like your secret weapons for a topnotch shopping journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Requirements&lt;/u&gt;&lt;/strong&gt;: Your customers are exploring your digital store. With real-time updates, they can instantly see the latest product availability, discounts, and any stock changes.Suppose You've just added a brand-new product to your backend. Now the frontend just have to show the updated product immediately on the product list without any refresh or reload the web app. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Think this&lt;/u&gt;&lt;/strong&gt;:How does this work?  Well, you can set up a backend server using technologies like Node.js and Express. Then, integrate web sockets, like Socket.io, into your backend to allow real-time communication between the server and your React frontend. or do this with front-end solution you can use heavy lifting state management with redux or context Api. It's a lot work my friend. &lt;/p&gt;

&lt;p&gt;But we can achieve all this magic even more easily with &lt;strong&gt;RxDB&lt;/strong&gt;. This JavaScript library smoothly integrates with your app, making real-time updates and offline functionality a breeze. With RxDB, managing your store's data becomes super handy, allowing you to focus on creating an exceptional shopping experience.&lt;/p&gt;

&lt;p&gt;And we all know the internet can be a bit unpredictable. This is where the &lt;em&gt;&lt;u&gt;offline functionality&lt;/u&gt;&lt;/em&gt; shines. Picture your customers on a train or at a café or with shaky Wi-Fi.or no wifi in while hiking in a mountain... No worries! They can still view products, add items to their cart, and even start the checkout process without a strong or no internet connection. Once they're back online,  everything smoothly syncs up with the remote server. &lt;/p&gt;

&lt;p&gt;These remarkable features aren't just about making shopping smoother.They make your website truly stand out. It's like giving your customers a virtual shopping flavor that rivals an in-person experience, all thanks to the magic of real-time updates and offline functionality. Your customers will absolutely love the freedom to shop anytime, anywhere, even if the internet decides to take a break.Also you can push realtime things like giving a live popup notification to your customer. Trust me, RxDB is that friend who want to less your hassle.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Key-Features: &lt;a&gt;
&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Browser-Storage:&lt;/strong&gt; RxdB provides a local database that we can use to store data directly in our client browser or any other JavaScript environment. Usually this storage limit depends on client device specs. But you can sure that, you will get at least 50MB according to their doc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multiple client Synchronization:&lt;/strong&gt;&lt;br&gt;
RxDB enables real-time data synchronization between clients(frontend) and servers(backend). This means that one changes made to the database on one client are automatically reflected to other clients connected to the same database. This feature is essential for creating collaborative and multi-user applications where data consistency is vital.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling Conflict:&lt;/strong&gt;&lt;br&gt;
In scenarios where multiple clients make changes to the same data simultaneously, conflicts can arise during synchronization. Not only this case, in time of sync between remote server and client conflict can be arise. RxDB offers built-in conflict resolution mechanisms called replication to help you handle and resolve conflicts smartly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reactive Programming:&lt;/strong&gt;&lt;br&gt;
As I discussed above RxDB offering reactive programming. It will give you a option to do anything when your database's any data changed. Basically In RxDB, each database query, when executed, returns an &lt;strong&gt;Observable&lt;/strong&gt; that represents the ongoing changes to the query result. This Observable emits different data sets over time as the data in the database changes. Then you have to &lt;strong&gt;subscribe&lt;/strong&gt; to an observable means you're expressing your interest in being notified whenever the Observable emits new values. When you subscribe to an Observable, you provide a callback function that will be executed each time the Observable emits a new value.  You can learn more about it here &lt;a href="https://rxjs.dev/guide/observable"&gt;RxJx&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query and Filter:&lt;/strong&gt;&lt;br&gt;
RxDB giving powerful querying capabilities that allow you to retrieve data from the database based on specific criteria. You can perform complex queries to fetch only the data you need, which can improve performance and reduce unnecessary data transfer. I am not sure but somehow the RxDB's query api is inspired by mongoose which is a widely used ODM for MongoDB&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Offline support:&lt;/strong&gt; Since RxDB use client browser storage for storing data, so obviously it has off line support.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modularity:&lt;/strong&gt; RxDB works with various JavaScript applications and frameworks. It can be used with different front-end libraries and back-end technologies like Node js, React, Vue, Angular and many more&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross Platform:&lt;/strong&gt; The feature I love most about RxDB is..&lt;br&gt;
Apart from web applications, RxDB can be used in other environments like Electron applications and mobile frameworks such as React Native. This allows you to maintain a consistent data management approach across different platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extendable:&lt;/strong&gt;&lt;br&gt;
You can extend RxDB's functionality by creating &lt;strong&gt;custom plugins&lt;/strong&gt; and &lt;strong&gt;hooks&lt;/strong&gt; according to your application's requirements&lt;/p&gt;



&lt;p&gt;I think it is quite long for you. Hope that you have gathered the basic idea about RxDB library and also encounter the fundamental that are efficient to start exploring RxDB doc. I had planned to write a complete article about how to integrate RxDB with react. But I am also not a fan of big article. So, I will make a separate article about how to intrigate RxDB with React JS. Happy learning, keep Exploring&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Reference VS Value in JavaScript - Part 1</title>
      <dc:creator>smrifat1411</dc:creator>
      <pubDate>Sat, 11 Mar 2023 22:42:09 +0000</pubDate>
      <link>https://dev.to/smrifat1411/reference-bnaam-value-in-javascript-25cf</link>
      <guid>https://dev.to/smrifat1411/reference-bnaam-value-in-javascript-25cf</guid>
      <description>&lt;p&gt;এই হ্যান্ডনোটে আমরা জাভাস্ক্রিপ্ট শেখার প্রথম অবস্থায় Data Type সংক্রান্ত যেসকল কুল টার্ম হরহামেশায় শুনি সেগুলো নিয়ে অল্পবিস্তর আলোচনা করবো। কোড করতে করতে নোট তুলবো। &lt;br&gt;
Primitive,Non-Primitive,Value,Reference,Objects,Stack,Heap,Dynamic,Static,pass by value etc...&lt;/p&gt;

&lt;p&gt;এই Word গুলো জাভাস্ক্রিপ্ট জানার সুবাদে আমরা অনেকবার শুনে ফেলসি। কিন্তু মাঝেমধ্যেই এগুলোর শানে-নুযূল আমার মতো Beginner জনতার বুঝতে একটু এলোমেলো লেগে যায় আরকি। সেজন্যই আজকের নোট&lt;/p&gt;



&lt;p&gt;JavaScript-এ আমরা যাই লিখি না কেনো সেগুলো Run করার জন্য তো Memory তে Save করে রাখতে হবে তাই না? এই Data সংরক্ষণ জাভাস্ক্রিপ্ট দুইভাবে করে। অর্থাৎ আমরা আমাদের কোডে Varriable, Function, Array, Object যায় লেখি না কেনো এগুলো পর্দার পিছনে মেমরিতে Save হয় দুইভাবে। দুইটার আচরণও আলাদা এজন্য। &lt;/p&gt;
&lt;h2&gt;
  
  
  Data Types:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Primitive Types : string, number, bigInt, boolean, undefined, symbol, null.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Non-Primitive Types: All Objects(Array,Function)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"string, numb.." এই সাতধরনের ডাটাকে প্রিমিটিভ টাইপ বলে। আমরা এগুলোর ডিটেইলস নিয়ে কথা বলবো না। আপনারা অবশ্যই এগুলো জানেন। &lt;/p&gt;

&lt;p&gt;তবে মজার বিষয় হলো নন-প্রিমিটিভ কিন্তু একজনেই। Object, হ্যা জাভাস্ক্রিপ্টে Object ই হলো একমাত্র Non-Primitive ডাটা টাইপ। ওয়েট,অবজেক্ট সম্পর্কে আমাদের সঠিক ধারনা আছে তো? না থাকলে অবশ্যই এই নোটটা আগে দেখে নেই।&lt;br&gt;
যেহেতু Function, Array এগুলাও জাভাস্ক্রিপ্টে দিনশেষে Object ই তাই এগুলাও নন-প্রিমিটিভ।&lt;/p&gt;


&lt;h2&gt;
  
  
  Stack and Heap :
&lt;/h2&gt;

&lt;p&gt;আমরা ইতিমধ্যে জেনে গেছি জাভাস্ক্রিপ্টে Data টাইপ দুই ধরনের। ধরন অনুযায়ী JavaScricpt &lt;br&gt;
 এই দুই টাইপের Data তার মেমোরিতে দুই জায়গায় সেভ করে।&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stack memory (সব primitive types ডাটা সেভ হয়)&lt;/li&gt;
&lt;li&gt;Heap memory (সব non-primitive types ডাটা সেভ হয়)&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Value:
&lt;/h2&gt;

&lt;p&gt;আমরা যখন Primitive type কোনো ডাটা তৈরি বা স্টোর করবো আমাদের মেমোরিতে তখন এটাকে বলে Value দিয়ে তৈরি বা Pass করা। এখন ভ্যালু দিয়ে কি তৈরি হবে,ভ্যালু দিয়ে তৈরি হবে Variable. অর্থাৎ Variable এর মধ্যে থাকবে Value. বিষয়গুলো মজার না? &lt;/p&gt;

&lt;p&gt;ভ্যারিয়েবল নিয়ে আর দুকথা নোট নেয়া যাক:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ভ্যারিয়েবলে আমরা ভ্যালু রাখতে পারি&lt;/li&gt;
&lt;li&gt;প্রয়োজনমতো সেই ভ্যারিয়েবলের নাম ধরে কোডে তার ভ্যালুর এক্সেস নিতে পারি। &lt;/li&gt;
&lt;li&gt;ভ্যালুটা পরিবর্তন মানে Re-Assign করতে পারি।&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example: let num = 10; let word = "hello";&lt;/p&gt;
&lt;h2&gt;
  
  
  Reference:
&lt;/h2&gt;

&lt;p&gt;এদিকে যখন Non-Primitive type কোনো ডাটা তৈরি করবো আমাদের মেমরিতে তখন এটাকে বলে রেফারেন্স(Reference) রাখা।&lt;/p&gt;

&lt;p&gt;Example: let myObj = {a:5}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;এজন্য অনেকেই Primitive কে Value টাইপ ও বলে। অনেকে আবার Non-Primitive কে Reference, Object টাইপ বলে আমাদের এলোমেলো করে দেয়।&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;টিপসঃ Object মানেই নন-প্রিমিটিভ/রেফারেন্স বাকি সব প্রিমিটিভ/ভ্যালু এভাবে মনে রাখা যেতে পারে।&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  এখন চলুন একটু Behind The Scene ঘুরে আসি।
&lt;/h2&gt;

&lt;p&gt;জাভাস্ক্রিপ্ট তার V8 ইঞ্জিনে যেখানে আমাদের কোড কম্পাইল,রান হয় সেখানে ডাটা স্টোর করে দুই জায়গায় 1.Stack ও 2. Heap&lt;br&gt;
এগুলো নিয়ে এখন মাথা না ঘামালেও চলবে, চলুন নিচের কোডটা একটু দেখি&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let bag = "Book";

let tholi;

tholi = bag;

bag = "Vegetables";

console.log(`I am inside bag - ${bag}`);
console.log(`I am inside Tholi - ${tholi}`);


// I am inside bag - Book
// I am inside Tholi - Vegetables
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;এখানে প্রথমে আমি bag নামে একটা Variable-এ "Book" String Value রাখসি। সব primitive ব্যাপার-স্যাপার। এরপরে আরেকটা  variable তৈরি করসি tholi নামে। এখন tholi-এর ভ্যালু হিসেবে পাস করছি bag কে। এটুকু আমাদের স্ট্যকে(Memory) কিভাবে জমা হলো চলুন সেটা আগে দেখে আসি&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6n5bw3aY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/levfhhnxs1gxmk1nicra.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6n5bw3aY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/levfhhnxs1gxmk1nicra.gif" alt="Frame-1" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;১. দ্বিতীয় লাইনে  আমি tholi ভ্যারিয়েবলটা তৈরি করলাম কিন্তু এর কোনো ভ্যালু দেই নি,তাই দ্বিতীয় লাইনে যখন কম্পাইলার আসবে সে এর ভ্যালু undefined সেট করবে।&lt;/p&gt;

&lt;p&gt;২. এরপরে যখন আমি tholi = bag স্ট্যাটমেন্ট রান করলাম আমার &lt;strong&gt;&lt;em&gt;tholi ভ্যারিয়েবলটিতে bagএর যে ভ্যালু সেটার একটা কপি তৈরি করে নিলো&lt;/em&gt;&lt;/strong&gt;।&lt;br&gt;
আমরা জানি ভ্যারিয়েবল ডিক্লেয়ার করার পরে এর নাম ধরে ডাকলে আমরা তার ভ্যালুটার এক্সেস পাই। bag এর ভ্যালু এখানে "Book". যেটাকে আমরা এসাইন করেছি tholi ভ্যারিয়েবলে। তাই এখন tholi এর ভ্যালুও "Book" ।&lt;/p&gt;

&lt;p&gt;এখন যদি আমি bag বা থলি যে কোনো একটার ভ্যালু এর পরে কোডে কোথাও পরিবর্তন বা Re-assign করি, তাহলে কি হবে? চলুন নিচের কোডটি রান করি।&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let bag = "Book";

let tholi;

tholi = bag;

bag = "Vegetables";

console.log(`I am inside bag - ${bag}`);
console.log(`I am inside Tholi - ${tholi}`);


//I am inside bag - Vegetables
//I am inside Tholi - Book
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;আউটপুটে আমরা দেখতে পাচ্ছি যে চতুর্থ লাইনে আমি bag এর Value পরিবর্তন করলেও সেটা আমার tholi ভ্যারিয়েবলের কোনো পরিবর্তন ঘটাচ্ছে না। কারন কি? &lt;/p&gt;

&lt;p&gt;উপরের বর্ণনাটুকু পড়লে আপনারা নিশ্চয় তা বুঝে গেছেন। এখানে bag আর tholi দুইটা স্বাধীন variable. যদিও তারা একি value হোল্ড করে (তৃতীয় লাইনে আমরা সেই কাজ করসি) কিন্তু মেমরিতে তাদের আলাদা আলাদা ঠিকানা আছে। তাই আমরা যদি তৃতীয় লাইনের পরে একটার ভ্যালু পরিবর্তন করি তাহলে আরেকটার উপরে কোনো প্রভাব পরবে না&lt;br&gt;&lt;br&gt;
চলুন স্ট্যাক দেখে আসি&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Ny-XleE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ropvrzsssq4ghucz4o40.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Ny-XleE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ropvrzsssq4ghucz4o40.gif" alt="Frame-2" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;কুইজঃ নিচের কোডটি দেখে এর আউটপুট অনুমান করুন এবং Stack এ Behind the Scene কি হচ্ছে সেটাও চিন্তা করুন।&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
let bag = "Book";&lt;br&gt;
let tholi;&lt;/p&gt;

&lt;p&gt;bag = "Vegetables";&lt;/p&gt;

&lt;p&gt;tholi = bag;&lt;/p&gt;

&lt;p&gt;console.log(&lt;code&gt;I am inside bag - ${bag}&lt;/code&gt;);&lt;br&gt;
console.log(&lt;code&gt;I am inside Tholi - ${tholi}&lt;/code&gt;);&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;হিন্টসঃ এখানে আমি tholi ভ্যারিয়েবলে bag এর ভ্যালু এসাইন করেছি, চতুর্থ লাইনে কিন্তু তার আগে আমি bag এর ভ্যালু পরিবর্তন করেছি। তাই চতুর্থ লাইনে এসে যখন আমার কোড রান করবে তখন সে থলির মধ্যে আমার ব্যাগের পরিবর্তিত ভ্যালুটা কপি করে রেখে দিবে।&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
