<?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: Marcis Bergmanis</title>
    <description>The latest articles on DEV Community by Marcis Bergmanis (@marcisbee).</description>
    <link>https://dev.to/marcisbee</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%2F307291%2Fdecc8d49-f7eb-416a-956c-17326f55e5ca.jpg</url>
      <title>DEV Community: Marcis Bergmanis</title>
      <link>https://dev.to/marcisbee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/marcisbee"/>
    <language>en</language>
    <item>
      <title>Showing off my crazy JS projects</title>
      <dc:creator>Marcis Bergmanis</dc:creator>
      <pubDate>Thu, 06 Apr 2023 08:14:18 +0000</pubDate>
      <link>https://dev.to/marcisbee/showing-off-my-crazy-js-projects-5fop</link>
      <guid>https://dev.to/marcisbee/showing-off-my-crazy-js-projects-5fop</guid>
      <description>&lt;p&gt;I've built so many JS projects in private and all of them were a new learning experience for me. I think I've mastered JavaScript enough to start sharing what I've learned and what did I make to learn it. That's why I've &lt;a href="https://discord.gg/a62gfaDW2e"&gt;created a Discord server for all things Front-End development&lt;/a&gt;. I can help you fight your JS code and share FE news as soon as I learn about them.&lt;/p&gt;

&lt;p&gt;I am strong believer in learning by doing, at least that's how my brain is wired to understand stuff. So I will also be sharing my crazy private projects there like: "Code editor that I've fully built using ".&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/-YlwF9Vh69k"&gt;
&lt;/iframe&gt;
&lt;br&gt;
If you want to join, feel free to use this invite link: &lt;a href="https://discord.gg/a62gfaDW2e"&gt;https://discord.gg/a62gfaDW2e&lt;/a&gt;&lt;br&gt;
Come say hello!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>discord</category>
      <category>webdev</category>
      <category>news</category>
    </item>
    <item>
      <title>Announcing new and simple state manager “Exome”</title>
      <dc:creator>Marcis Bergmanis</dc:creator>
      <pubDate>Sat, 17 Apr 2021 09:12:56 +0000</pubDate>
      <link>https://dev.to/marcisbee/announcing-new-and-simple-state-manager-exome-2e6i</link>
      <guid>https://dev.to/marcisbee/announcing-new-and-simple-state-manager-exome-2e6i</guid>
      <description>&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt;: I created new state library called &lt;a href="https://github.com/Marcisbee/exome" rel="noopener noreferrer"&gt;Exome&lt;/a&gt; (works with React and there's a PR for Vue too (excuse me, that sounded like a pokemon)). The end.&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Let me introduce myself first. I'm working as a front-end dev for as long as I can remember. Since before the days of jQuery dominance even. So I've seen a lot from dead simple JS libraries to utterly complex ones and again back to simple ones and so on. When I started learning Redux, NgRx and Vuex back in a day it was a high hill to climb at first always wishing for something easier. Much easier, like a plain object being state easier.&lt;/p&gt;

&lt;p&gt;So I started tinkering with different ideas of how I would like my ideal state manager to look and feel years ago. I remember having random ideas at random times and just dropped them in notes. I never did anything with those because none of them really felt good enough.&lt;/p&gt;

&lt;p&gt;Until now when I reached a point when starting new project where working with deeply nested tree structures was a must have. Since that is one of Redux (and I'd say the whole flux architecture for that matter) core problems, I went with &lt;a href="https://github.com/pmndrs/valtio" rel="noopener noreferrer"&gt;valtio&lt;/a&gt;, a library by Pmndrs. And it was great at first, but then I started to see a real mess in code with my made up actions and selectors making sense less and less. And line between what gets selected from state and what updated became blurred together. So I knew that I had only one option, to finally figure out my dream state manager.&lt;/p&gt;

&lt;h1&gt;
  
  
  From idea to library
&lt;/h1&gt;

&lt;p&gt;I set a few goals for state manager I wanted:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Must have actions (in a sense that it would be the only way to modify state);&lt;/li&gt;
&lt;li&gt;Must integrate with Redux Devtools and to see deeply nested objects right away, not clicking through tree to find exact one I'm looking for;&lt;/li&gt;
&lt;li&gt;Must be typed via TypeScript, I mean when working with data, there must be some guards and of course that sweet autocomplete;&lt;/li&gt;
&lt;li&gt;Must be able to save and load as a string (since in my case I needed a way to save state in a file and restore it);&lt;/li&gt;
&lt;li&gt;Must be dead simple so any junior developer can get productive right away;&lt;/li&gt;
&lt;li&gt;Must not bottleneck the view renderer (must be performant).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So those were my initial goals and in a single evening I came up with &lt;a href="https://github.com/Marcisbee/exome" rel="noopener noreferrer"&gt;Exome&lt;/a&gt; and developed a prototype. I was so happy with it that I decided to make it open source. It really hits all of the goals I set and more. &lt;del&gt;Only issue is that &lt;a href="https://caniuse.com/proxy" rel="noopener noreferrer"&gt;it doesn't support IE11&lt;/a&gt;, since it uses Proxy. But in my case it didn't matter.&lt;/del&gt; Not true anymore! It &lt;a href="https://github.com/Marcisbee/exome#ie-support" rel="noopener noreferrer"&gt;support IE11&lt;/a&gt; too.&lt;/p&gt;

&lt;h1&gt;
  
  
  Examples
&lt;/h1&gt;

&lt;p&gt;So to start off here's a primitive counter example (click on number to increment it).&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/exome-counter-96qfq"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;And that's it, no providers, no contexts, no boilerplate. Store is just a class. Properties are state values and methods are actions. Whenever action is called, state is updated and wired view components (via &lt;code&gt;useStore&lt;/code&gt;) are rendered. It updates only those components that uses particular Exome instance in &lt;code&gt;useStore&lt;/code&gt; hook. It's simple as that.&lt;/p&gt;

&lt;p&gt;Ok everyone can do a counter example. What about that deeply nested tree part that was in my goals. Aah great question. So I threw up a simple router example for this.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/exome-routes-w2yq4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is more complex one. I wanted to demonstrate here that we can have Store that can have multiple Tabs and those Tabs can also have multiple Items. So it's a nested tree. Just pass child Exome instance through &lt;code&gt;useStore&lt;/code&gt; and that child component will be wired.&lt;/p&gt;

&lt;h1&gt;
  
  
  Devtools
&lt;/h1&gt;

&lt;p&gt;Working with Redux Devtools to examine Exome state is a breeze too. No need to dig deep into state tree to find Exome you're looking for. But if you want to see whole tree, that's available too (all Exome childs are examinable in full tree view).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F1%2ACkoYissBpbKxGmiMwYb-eg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F1%2ACkoYissBpbKxGmiMwYb-eg.png" alt="Exome state explored in Redux Devtools"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Since devtools have &lt;a href="https://github.com/zalmoxisus/redux-devtools-extension/issues/737" rel="noopener noreferrer"&gt;weird bugs&lt;/a&gt; when using &lt;code&gt;serializedType&lt;/code&gt; every Exome will have &lt;code&gt;$$exome_id&lt;/code&gt; until those bugs are resolved.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Saving and loading state is described in details in API docs (&lt;a href="https://github.com/Marcisbee/exome#savestate" rel="noopener noreferrer"&gt;https://github.com/Marcisbee/exome#savestate&lt;/a&gt;).&lt;/p&gt;

&lt;h1&gt;
  
  
  Performance
&lt;/h1&gt;

&lt;p&gt;It's great! And will be more and more optimised as library matures.&lt;/p&gt;

&lt;p&gt;To get the feel of how this library performs, I created a &lt;a href="https://github.com/Marcisbee/exome/tree/main/benchmark#benchmarks" rel="noopener noreferrer"&gt;benchmarks&lt;/a&gt; (really, really primitive ones). And the results are quite good, in fact Exome seems to be the fastest library out of what I've tested (at least on my machine — Macbook Pro 2020 M1). And here are the results:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1008%2F1%2Ae-Dyk7YEyiNuZwVFMo0wPg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1008%2F1%2Ae-Dyk7YEyiNuZwVFMo0wPg.png" alt="Render component benchmarks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a simple counter example in React, that gets rendered in first benchmark. And in second one count gets incremented and rendered via view update.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1008%2F1%2AbCKOoKVCAnuYfBOZqA7R0w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1008%2F1%2AbCKOoKVCAnuYfBOZqA7R0w.png" alt="Increment action benchmarks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please note that these benchmarks are not intended to make any library look bad (in fact they all are really great). Main intention is to see where Exome stands in terms of Performance and where and how to improve it. And I know those are very primitive benchmarks, but I don't really want to spend a lot of my time to create real world apps for each store. Maybe in future.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;There are more perks to Exome that we didn't explore, but most of them are explained in &lt;a href="https://github.com/Marcisbee/exome#readme" rel="noopener noreferrer"&gt;readme&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The most exciting one is that micro-frontends can share single state between them. I created a &lt;a href="https://codesandbox.io/s/vue-exome-lchcp?file=/src/App.vue" rel="noopener noreferrer"&gt;tiny example&lt;/a&gt; where I created single Exome store and passed it to React and Vue. Whenever something changes in state, it gets synced across all frameworks that utilise Exome middleware. It just works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F2000%2F1%2AAdwM144pGoIBwzdVMV8VnQ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F2000%2F1%2AAdwM144pGoIBwzdVMV8VnQ.gif" alt="Vue counter and React counter sharing counter state"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm really excited for what future brings. For now I'm gonna go dogfeed and battle test this library. See ya later.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Marcisbee" rel="noopener noreferrer"&gt;
        Marcisbee
      &lt;/a&gt; / &lt;a href="https://github.com/Marcisbee/exome" rel="noopener noreferrer"&gt;
        exome
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      🔅 State manager for deeply nested states
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
