<?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: Risyad Rais Rafsanjani</title>
    <description>The latest articles on DEV Community by Risyad Rais Rafsanjani (@atmorojo).</description>
    <link>https://dev.to/atmorojo</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%2F962405%2F336ca71b-8e2d-4218-b2a4-a9dea218eee2.jpeg</url>
      <title>DEV Community: Risyad Rais Rafsanjani</title>
      <link>https://dev.to/atmorojo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/atmorojo"/>
    <language>en</language>
    <item>
      <title>The Elm Architecture with React</title>
      <dc:creator>Risyad Rais Rafsanjani</dc:creator>
      <pubDate>Wed, 24 Dec 2025 04:37:13 +0000</pubDate>
      <link>https://dev.to/atmorojo/the-elm-architecture-with-react-2p1m</link>
      <guid>https://dev.to/atmorojo/the-elm-architecture-with-react-2p1m</guid>
      <description>&lt;p&gt;I was not interested in learning front-end development so much. Not really hated it. I just underestimated it so much that I think I'll learn it in an instant. Oh, boy. My arrogance bit me hard!&lt;/p&gt;

&lt;p&gt;My front-end development journey was not so straightforward. From JQuery around 2014, I skipped all the way to _hyperscript (2023? Can't remember exactly). Then I started learning Rescript-react, Elm, exploring what's out there other than JS to build a front-end. Found Preact only to help me understand a bit more of React, and going back to Rescript-React only to rediscover Elm with the infamous The Elm Architecture. At this point, I'm still waiting for the next twist.&lt;/p&gt;

&lt;p&gt;State management is a hell of a pain to dance around to. So I kind of jokingkly said to my learning partner (chatGPT lol). What if I do React, but do the state management like Elm? On top of Rescript? And boom. Everything's fallen to it's place. Reducer, ADTs, etc, etc. Now it's been weeks and I'm still having fun learning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Imitating Elm
&lt;/h2&gt;

&lt;p&gt;Imitating Elm to a TEA (got it?) using Rescript means you get the architecture and noisy compiler. And I'm in for it. &lt;/p&gt;

&lt;p&gt;The architecture is simple. If I understand it correctly, the architecture is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Model -&amp;gt; Update -&amp;gt; View
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model is the state of the application. The update is the function that updates the model. The view changes matching the shape of the model (state).&lt;/p&gt;

&lt;p&gt;Heh, I know. I'm bad at explaining so let's just jump into it. Read this snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rescript"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;sub_1Model&lt;/span&gt;: &lt;span class="nn"&gt;Sub_1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;,
    &lt;span class="n"&gt;sub_2Model&lt;/span&gt;: &lt;span class="nn"&gt;Sub_2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;,
    &lt;span class="n"&gt;sub_3Model&lt;/span&gt;: &lt;span class="nn"&gt;Sub_3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;,
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt;: &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;sub_1Model&lt;/span&gt;: &lt;span class="nn"&gt;Sub_1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;,
  &lt;span class="n"&gt;sub_2Model&lt;/span&gt;: &lt;span class="nn"&gt;Sub_2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;,
  &lt;span class="n"&gt;sub_3Model&lt;/span&gt;: &lt;span class="nn"&gt;Sub_3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;,
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sub_1Msg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Sub_1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sub_2Msg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Sub_2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sub_3Msg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Sub_3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;update&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;: &lt;span class="n"&gt;model&lt;/span&gt;, &lt;span class="n"&gt;msg&lt;/span&gt;: &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;: &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sub_1Msg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sub1msg&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="n"&gt;sub_1Model&lt;/span&gt;: &lt;span class="nn"&gt;Sub_1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sub1msg&lt;/span&gt;, &lt;span class="n"&gt;model&lt;/span&gt;.&lt;span class="n"&gt;sub_1Model&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
      &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sub_2Msg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sub2msg&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="n"&gt;sub_2Model&lt;/span&gt;: &lt;span class="nn"&gt;Sub_2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sub2msg&lt;/span&gt;, &lt;span class="n"&gt;model&lt;/span&gt;.&lt;span class="n"&gt;sub_2Model&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
      &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Sub_3Msg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sub3msg&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="n"&gt;sub_3Model&lt;/span&gt;: &lt;span class="nn"&gt;Sub_3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sub3msg&lt;/span&gt;, &lt;span class="n"&gt;model&lt;/span&gt;.&lt;span class="n"&gt;sub_3Model&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;How'd that work under React, you asked?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rescript"&gt;&lt;code&gt;  &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;, &lt;span class="n"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;useReducer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;, &lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Boom. Reducer, baby!&lt;/p&gt;

&lt;p&gt;See! I'm really bad at explaining. I hope future me know how to make this make sense since I'm writing this for him.&lt;/p&gt;

</description>
      <category>react</category>
      <category>rescript</category>
      <category>elm</category>
      <category>statemanagement</category>
    </item>
    <item>
      <title>Using SQLite with Ecto in a Phoenix App</title>
      <dc:creator>Risyad Rais Rafsanjani</dc:creator>
      <pubDate>Thu, 26 Jan 2023 06:57:37 +0000</pubDate>
      <link>https://dev.to/atmorojo/using-sqlite-with-ecto-in-a-phoenix-app-1i34</link>
      <guid>https://dev.to/atmorojo/using-sqlite-with-ecto-in-a-phoenix-app-1i34</guid>
      <description>&lt;p&gt;Phoenix (or Ecto) defaults PostgreSQL as their database of choice. What if you just want to do something simple or just start learning Phoenix and too lazy to set up a Postgres server (like me)?&lt;/p&gt;

&lt;p&gt;After setting up your Erlang and Elixir in your machine, you need to install &lt;code&gt;hex&lt;/code&gt;. If you haven't had it installed, run this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mix local.hex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you need to install Phoenix application generator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mix archive.install hex phx_new
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To kick start your Phoenix project, run this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mix phx.new sqlite_app &lt;span class="nt"&gt;--database&lt;/span&gt; sqlite3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you're ready to develop your next awesome Phoenix project with SQLite.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Happened?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;--database&lt;/code&gt; flag tells the generator that we want to use SQLite in our project and added &lt;code&gt;ecto_sqlite3&lt;/code&gt; as a dependency so we can use it with &lt;code&gt;Ecto&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Actually, Phoenix is well documented (and from what I heard, Elixir projects are generally well documented). You can find most of what you want to do when kickstarting your Phoenix project in &lt;a href="https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html" rel="noopener noreferrer"&gt;this hexdocs page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mix ecto.create
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to create your SQLite database file in your project direcory.&lt;/p&gt;

&lt;p&gt;I hope this helps and hope you have some fun times ahead!&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>phoenix</category>
      <category>sqlite</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
