<?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: Dennis Quesada Cruz</title>
    <description>The latest articles on DEV Community by Dennis Quesada Cruz (@dcruz1990).</description>
    <link>https://dev.to/dcruz1990</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%2F111507%2F095f0ae9-aad7-409e-9260-482f5c5e99be.jpg</url>
      <title>DEV Community: Dennis Quesada Cruz</title>
      <link>https://dev.to/dcruz1990</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dcruz1990"/>
    <language>en</language>
    <item>
      <title>Changing AntD locale dynamically</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Mon, 17 Jan 2022 21:08:53 +0000</pubDate>
      <link>https://dev.to/dcruz1990/changing-antd-locale-dynamically-3e15</link>
      <guid>https://dev.to/dcruz1990/changing-antd-locale-dynamically-3e15</guid>
      <description>&lt;p&gt;Hello devs, it's new year and here i'm struggling with React and AntD. &lt;br&gt;
I'm trying to change AntD locale dynamically. As documentation refers, AntD has a  context that wraps , its receives 'lang' as a prop.&lt;br&gt;
So here i'm doing this dumb thing:&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="nx"&gt;i18n&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;./i18n&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&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;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StrictMode&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;ConfigProvider&lt;/span&gt; &lt;span class="nx"&gt;locale&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;i18n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;languages&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="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&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="sr"&gt;/ConfigProvider&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;/React.StrictMode&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;,
&lt;/span&gt;  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And of course, when i change the language nothing happens, the docs says that we have to set up a local state or so, but i'm really lost there. Any idea?&lt;/p&gt;

</description>
      <category>help</category>
      <category>react</category>
    </item>
    <item>
      <title>Creando un sencillo sistema de notificaciones en Vue3 con TailwindCSS (MerakiUI)</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Mon, 25 Oct 2021 20:42:15 +0000</pubDate>
      <link>https://dev.to/dcruz1990/creando-un-sencillo-sistema-de-notificaciones-en-vue3-con-tailwindcss-merakiui-1017</link>
      <guid>https://dev.to/dcruz1990/creando-un-sencillo-sistema-de-notificaciones-en-vue3-con-tailwindcss-merakiui-1017</guid>
      <description>&lt;p&gt;Hola a todos, dicen por ahí que es bueno escribir artículos técnicos porque así reafirmas lo aprendido, pues, en esta ocasión, voy a seguir con Vue3 y hoy particularmente con TailwindCSS y MerakiUI, creando un sencillo sistema de notificaciones para tu app.&lt;/p&gt;

&lt;h3&gt;
  
  
  TailwindCSS
&lt;/h3&gt;

&lt;p&gt;Es una potente librería de utilidades para CSS, te ahorrará mucho tiempo a la hora de escribir tus estilos, aunque, NO reemplaza al CSS puro. &lt;/p&gt;

&lt;h3&gt;
  
  
  MerakiUI
&lt;/h3&gt;

&lt;p&gt;Una librería de componentes responsivos y limpios, basada en Flexbox y Grid, completamente responsiva. &lt;/p&gt;

&lt;h3&gt;
  
  
  Motivación
&lt;/h3&gt;

&lt;p&gt;En mi tiempo libre por las noches, he estado ¨rehaciendo¨ una app que tengo online y en producción desde principios de año, he querido hacerla lo mas ligera posible y por eso la estoy rediseñando y reescribiendo desde 0 con Vue3 y TailwindCSS, actualmente esta con Vue2 y Vuetify + otras deps, y no por hecharle tierra a Vuetify, pero está bastante pesadita. &lt;/p&gt;

&lt;h3&gt;
  
  
  Notificar o no notificar?
&lt;/h3&gt;

&lt;p&gt;Una de las cosas mas importantes en tu app y UX es la interacción con el usuario, las buenas prácticas dictan de informar al usuario qué esta pasando con sus acciones, si se completaron o si terminaron en un error, aquí entran las alertas, hay N+1 librerías open source que te permiten gestionarlas, pero quiero depender lo menos de 3ros, asi que me puse a intentar construir mi propio sistema.&lt;/p&gt;

&lt;h3&gt;
  
  
  Manos a la obra
&lt;/h3&gt;

&lt;p&gt;Lo primero que tuve en mente fue armar un composable que gestionara todo lo de las alertas&lt;/p&gt;

&lt;p&gt;Archivo: &lt;code&gt;useToast.ts&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&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;ref&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;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Este arreglo contendrá las notificaciones&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ToastOptions&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="nx"&gt;useToast&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="c1"&gt;// Empuja una nueva alerta al arreglo&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addAlert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ToastOptions&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;messages&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="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;options&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="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;options&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="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;success&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="c1"&gt;// A los 3 segundos, que se disipe.&lt;/span&gt;
        &lt;span class="nf"&gt;setTimeout&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;messages&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="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;removeAlert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;messages&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="nf"&gt;findIndex&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&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;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;options&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="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="c1"&gt;// Remueve el elemento del arreglo de mensajes&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;removeAlert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&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;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&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="nx"&gt;messages&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="nf"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&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="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="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;addAlert&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;removeAlert&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;useToast&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;De esa forma podemos traernos &lt;code&gt;useToast()&lt;/code&gt; a cualquier parte de nuestra app.&lt;/p&gt;

&lt;p&gt;Continuamos con el componente:&lt;br&gt;
Archivo: &lt;code&gt;alert.vue&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt;
    &lt;span class="na"&gt;v-for=&lt;/span&gt;&lt;span class="s"&gt;"alert, index in messages"&lt;/span&gt;
    &lt;span class="na"&gt;:key=&lt;/span&gt;&lt;span class="s"&gt;"index"&lt;/span&gt;
    &lt;span class="na"&gt;ref=&lt;/span&gt;&lt;span class="s"&gt;"item"&lt;/span&gt;
    &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"absolute right-5 top-5 flex w-full max-w-sm mx-auto overflow-hidden bg-white rounded-lg shadow-lg dark:bg-gray-800 animate-fadeIn"&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt;
      &lt;span class="na"&gt;:class=&lt;/span&gt;&lt;span class="s"&gt;"`flex items-center justify-center w-12  $&lt;/span&gt;{alert.type === 'error' ? 'bg-red-500' : 'bg-green-500'}`"
    &amp;gt;
      &lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt;
        &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"w-6 h-6 text-white fill-current"&lt;/span&gt;
        &lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;"0 0 40 40"&lt;/span&gt;
        &lt;span class="na"&gt;xmlns=&lt;/span&gt;&lt;span class="s"&gt;"http://www.w3.org/2000/svg"&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt;
          &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M20 3.36667C10.8167 3.36667 3.3667 10.8167 3.3667 20C3.3667 29.1833 10.8167 36.6333 20 36.6333C29.1834 36.6333 36.6334 29.1833 36.6334 20C36.6334 10.8167 29.1834 3.36667 20 3.36667ZM19.1334 33.3333V22.9H13.3334L21.6667 6.66667V17.1H27.25L19.1334 33.3333Z"&lt;/span&gt;
        &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"px-4 py-2 -mx-3"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mx-3 w-11/12"&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;:class=&lt;/span&gt;&lt;span class="s"&gt;"`font-semibold $&lt;/span&gt;{alert.type === 'error' ? 'text-red-500' : 'text-green-500'} dark:text-red-400`"
        &amp;gt;&lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;alert&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="s1"&gt;error&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="s1"&gt;Error&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="s1"&gt;Completado&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&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;"text-sm text-gray-600 dark:text-gray-200 w-full"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&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="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"ts"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;PropType&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;vue&lt;/span&gt;&lt;span class="dl"&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;defineComponent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;PropType&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ToastOptions&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;default&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="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&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;El componente recibirá como props el arreglo de mensajes que habíamos definido en &lt;code&gt;useToast()&lt;/code&gt;, ya luego solo queda usarlo en &lt;code&gt;App.vue&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Archivo: &lt;code&gt;App.vue&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;Alert&lt;/span&gt; &lt;span class="na"&gt;:messages=&lt;/span&gt;&lt;span class="s"&gt;"messages"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;default-vue&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="k"&gt;template&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="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"ts"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;DefaultVue&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;./layouts/Default.vue&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;Alert&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/common/alert.vue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineComponent&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;vue&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;useToast&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;./utils/useToast&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;defineComponent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;DefaultVue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Alert&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;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;setup&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;messages&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useToast&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="nx"&gt;messages&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="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&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;Para llamar a la alerta desde cualquier lado:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;useToast&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;./useToast&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;addAlert&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useToast&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nf"&gt;addAlert&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="nf"&gt;generateGuid&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;span class="na"&gt;message&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="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Resultando en:&lt;br&gt;
&lt;a href="https://media.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%2Fnjrmrjebke9v1m5344a6.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjrmrjebke9v1m5344a6.gif" alt="Alertas con MerakUI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Y hasta aquí este sencillo artículo, espero les haya servido de algo&lt;/p&gt;

&lt;p&gt;¿Para mejorarlo?:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hacer que una alerta este por debajo de la otra y se acumulen&lt;/li&gt;
&lt;li&gt;Adicionar un boton de cerrar la alerta.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cualquier comentario y/o crítica es bienvenida!&lt;/p&gt;

</description>
      <category>vue</category>
      <category>tailwindcss</category>
      <category>spanish</category>
    </item>
    <item>
      <title>Modularizando el store de Vuex</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Sun, 08 Aug 2021 22:07:16 +0000</pubDate>
      <link>https://dev.to/dcruz1990/modularizando-el-store-de-vuex-3955</link>
      <guid>https://dev.to/dcruz1990/modularizando-el-store-de-vuex-3955</guid>
      <description>&lt;p&gt;Hola amigos, en este post voy a estar compartiendo con ustedes cómo modularizar el store de Vuex. Vuex nos permite tener un store en nuestra app, un lugar donde se va a centralizar información necesaria que sea usable por múltiples componentes.&lt;/p&gt;

&lt;p&gt;Como refiere su documentación, hay veces que tu store va a crecer mucho debido al alcance que tenga tu app, es por eso que hay que recurrir a la modularización para que todo quede mas organizado y legible. Quizás tengas manejo de autenticación, manejo de perfiles y modelos etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creando el módulo
&lt;/h3&gt;

&lt;p&gt;El primer paso que debemos hacer es crear un nuevo archivo dentro del directorio &lt;code&gt;/store&lt;/code&gt; con el nombre representativo de lo que estamos modularizando, en mi caso es User, así que voy a terminar con un archivo user.js dentro del directorio store.&lt;/p&gt;

&lt;p&gt;Seguidamente lo vamos a popular con un objeto que contiene las mismas propiedades que el store.&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;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserModule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&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="na"&gt;userPets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;token&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="na"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkAuth&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
 &lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="na"&gt;mutations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Tus mutations aquí&lt;/span&gt;
 &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="na"&gt;actions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Tus actions aquí.&lt;/span&gt;
 &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="c1"&gt;// Demás propiedades del Store de Vuex&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Y bien, ya así tenemos hecho nuestro módulo, pero, como lo conectamos con el store principal? &lt;/p&gt;

&lt;p&gt;Sencillo, basta con traernos el módulo a nuestro index.js dentro del directorio store.&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;UserModule&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;./user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// Importar el módulo recién creado&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Vuex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Store&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="p"&gt;(...)&lt;/span&gt;
  &lt;span class="na"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;UserModule&lt;/span&gt; &lt;span class="c1"&gt;// Especificamos que usaremos el módulo&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Tu estado general &lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;mutations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&gt;// Tus mutations generales&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// Demás propiedades del store. ej: Getters..&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Y listo, ya Vuex sabe que debe importar nuestro recién creado UserModule en el store. Es válido aclarar que los módulos pueden acceder al estado general en sus actions, pasando a &lt;strong&gt;rootState&lt;/strong&gt; como parámetro. Veamos un ejemplo:&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;// Un action cualquiera, pasamos rootState dentro del objeto deconstruido&lt;/span&gt;
&lt;span class="nx"&gt;isAdopted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rootState&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;petid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;petService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;adoptPet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rootState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;petid&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
        &lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&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="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;Otra cosa que podemos destacar, es que los actions dentro de tus módulos van todos a un solo arreglo. Por eso debes cuidar de no escribir 2 actions con el mismo nombre en varios módulos, a no ser que establezcas la opción de &lt;strong&gt;namespaces&lt;/strong&gt;, lo cual si permitiría varios actions con el mismo nombre.&lt;/p&gt;

&lt;h3&gt;
  
  
  Accediendo al estado modularizado
&lt;/h3&gt;

&lt;p&gt;Como refiere su documentación, desde nuestros componentes podemos acceder al estado de la forma:&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;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="c1"&gt;// -&amp;gt; El estado de `UserModule`&lt;/span&gt;
&lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="c1"&gt;// -&amp;gt; El estado de `x` módulo que tengamos&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Resumiendo
&lt;/h3&gt;

&lt;p&gt;Bien, y esto ha sido todo, como ven es muy sencillo y por su puesto, hay más opciónes que tenemos a disposición para mejorar nuestros módulos.&lt;/p&gt;

&lt;p&gt;Repaso:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Crear un archivo JS y dentro exportar un objeto con un estado, actions, mutations, getters que deseemos aislar.&lt;/li&gt;
&lt;li&gt;Importar en el store index dicho módulo y pasarlo en la propiedad de &lt;strong&gt;modules&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Consumirlo en los componentes con &lt;code&gt;store.state.modulox&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>spanish</category>
    </item>
    <item>
      <title>What's the proper way to run a DotNet ef migrations when deploying with Docker</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Wed, 27 Jan 2021 02:23:01 +0000</pubDate>
      <link>https://dev.to/dcruz1990/what-s-the-proper-way-to-run-a-dotnet-ef-migrations-when-deploying-with-docker-44c8</link>
      <guid>https://dev.to/dcruz1990/what-s-the-proper-way-to-run-a-dotnet-ef-migrations-when-deploying-with-docker-44c8</guid>
      <description>&lt;p&gt;Hello Devs, im looking for the best aproach to update the app database (DotNet WebApi) when deploying to a Docker Container. This is what i have so far:&lt;br&gt;
1 - Tried to run a migration inside the startup class using context.Database.Migrate(), for some reason didnt work. &lt;br&gt;
2 - Compose build and up, then manually 😅 run bash inside the aspnet container, install ef tool, add the migration and update database. &lt;br&gt;
3 - Get the SQL script runing DotNet ef migrations script and putting it inside a seed. SQL on the Postgres container. &lt;/p&gt;

&lt;p&gt;Im wondering if there is a automatic way to do that? &lt;/p&gt;

</description>
      <category>help</category>
      <category>dotnet</category>
      <category>docker</category>
    </item>
    <item>
      <title>2020. Mi jornada hasta hoy.</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Wed, 23 Dec 2020 16:50:45 +0000</pubDate>
      <link>https://dev.to/dcruz1990/2020-mi-jornada-hasta-hoy-34j9</link>
      <guid>https://dev.to/dcruz1990/2020-mi-jornada-hasta-hoy-34j9</guid>
      <description>&lt;p&gt;Si, ya lo sé, este año ha sido todo un problema, aunque siempre algo bueno se le pudo sacar. En este post, mi primero de hecho, voy a contarles un poco sobre lo que ha sido mi experiencia con la programación.&lt;/p&gt;

&lt;p&gt;Nunca estuve más cerca de la programación antes, a pesar de que me gradué como IT en 2008, no había visto/considerado programar seriamente. Tal vez porque uno no encuentra trabajo como desarrollador tan fácil. Luego de salir del instituto, siempre trabajé dando soporte técnico hasta que cambié de trabajo para una empresa en donde me tuve que involucrar un poco más con programar.&lt;/p&gt;

&lt;p&gt;Como muchos, comencé con Python, y un libro muy bueno de la serie Head First. Fue la recomendación de un amigo, que dominara primero el lenguaje antes de saltar de lleno a un Framework y así lo hice.&lt;/p&gt;

&lt;p&gt;Django fue mi primera experiencia, y aquí tiene tremenda popularidad, así que estuve haciendo el tutorial oficial y sintiéndome cómodo con el framework. Ah claro, ya tenía algo de experiencia con HTML y CSS muy básico. Aprender el ciclo de vida de los requests y el modelo vista plantilla fue muy interesante y enriquecedor.&lt;/p&gt;

&lt;p&gt;Luego tuve la oportunidad de crear, con la ayuda de la comunidad de Django Cuba en Telegram (y la de Dev.To también), un pequeño sistema para el departamento comercial, usando Django&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/dcruz1990"&gt;
        dcruz1990
      &lt;/a&gt; / &lt;a href="https://github.com/dcruz1990/django-misclientes"&gt;
        django-misclientes
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A simple django app to manage clients
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://camo.githubusercontent.com/5509799baa0383faa4d5076f1d8f4c2cd5ae8e1e4c3dfd8b63f75ab7e3f0caee/68747470733a2f2f692e6962622e636f2f437772637172572f4172636f2d4c696e75782d323032302d30332d31382d313538343534353639362d73637265656e73686f742d31333636783736382e6a7067"&gt;&lt;img src="https://camo.githubusercontent.com/5509799baa0383faa4d5076f1d8f4c2cd5ae8e1e4c3dfd8b63f75ab7e3f0caee/68747470733a2f2f692e6962622e636f2f437772637172572f4172636f2d4c696e75782d323032302d30332d31382d313538343534353639362d73637265656e73686f742d31333636783736382e6a7067" alt="MisClientes"&gt;&lt;/a&gt;
&lt;a rel="noopener noreferrer" href="https://camo.githubusercontent.com/560753b5954c281bab2c0eabc8b3933bdfbb3a116a14c8327a1337f1a5bcb79c/68747470733a2f2f692e6962622e636f2f337a4852586b762f4172636f2d4c696e75782d323032302d30332d31382d313538343534353732372d73637265656e73686f742d31333636783736382e6a7067"&gt;&lt;img src="https://camo.githubusercontent.com/560753b5954c281bab2c0eabc8b3933bdfbb3a116a14c8327a1337f1a5bcb79c/68747470733a2f2f692e6962622e636f2f337a4852586b762f4172636f2d4c696e75782d323032302d30332d31382d313538343534353732372d73637265656e73686f742d31333636783736382e6a7067" alt="MisClientes"&gt;&lt;/a&gt;
&lt;a rel="noopener noreferrer" href="https://camo.githubusercontent.com/cf39109a3b5823aabfa7ad47cf34e0f9ec7732c52063f154edc18183f011bb8d/68747470733a2f2f692e6962622e636f2f6d7644714e74442f4172636f2d4c696e75782d323032302d30332d31382d313538343534353733392d73637265656e73686f742d31333636783736382e6a7067"&gt;&lt;img src="https://camo.githubusercontent.com/cf39109a3b5823aabfa7ad47cf34e0f9ec7732c52063f154edc18183f011bb8d/68747470733a2f2f692e6962622e636f2f6d7644714e74442f4172636f2d4c696e75782d323032302d30332d31382d313538343534353733392d73637265656e73686f742d31333636783736382e6a7067" alt="MisClientes"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
django-misclientes&lt;/h1&gt;
&lt;p&gt;A simple django app to manage clients&lt;/p&gt;
&lt;p&gt;Thanks to all &lt;a href="https://t.me/DjangoCuba" rel="nofollow"&gt;Django Cuba&lt;/a&gt; Telegram Group!!!!!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Luis Miguel Pozo Gonzalez&lt;/li&gt;
&lt;li&gt;&lt;a class="mentioned-user" href="https://dev.to/codeshard"&gt;@codeshard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a class="mentioned-user" href="https://dev.to/felix"&gt;@felix&lt;/a&gt; Pupo&lt;/li&gt;
&lt;li&gt;
&lt;a class="mentioned-user" href="https://dev.to/guillermo"&gt;@guillermo&lt;/a&gt; Roig&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Create virtual environment and install requirements&lt;/h2&gt;
&lt;h3&gt;
Clone this repository&lt;/h3&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;git clone https://github.com/dcruz1990/django-misclientes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;
Define virtualenv environment&lt;/h3&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;virtualenv -p python .venv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;
Install requirements&lt;/h3&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;pip install -r requirements
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;
Install WeasyPrint&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Please follow &lt;a href="https://weasyprint.readthedocs.io/en/latest/install.html" rel="nofollow"&gt;this official guide&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you are using Debian like distributions you need to install these packages:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sudo apt-get install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
Run server in local environment&lt;/h2&gt;
&lt;h3&gt;
Run makemigrations&lt;/h3&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;python manage.py makemigrations
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;
Run migrations&lt;/h3&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;python manage.py migrate
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;
Compile .po to .mo&lt;/h3&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;python manage.py compilemessages
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;
Update assets&lt;/h3&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;python manage.py collectstatic --noinput
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;
Run server for development&lt;/h3&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;python manage.py runserver
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;
Visit you application&lt;/h3&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;http://localhost:8000/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
Run with Docker&lt;/h2&gt;
&lt;h3&gt;
Requirements&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;li&gt;docker-compose&lt;/li&gt;
&lt;li&gt;Docker image for python &amp;gt;= 3.6 (&lt;a href="https://hub.docker.com/_/python" rel="nofollow"&gt;https://hub.docker.com/_/python&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Docker image for nginx:alpine (&lt;a href="https://hub.docker.com/_/nginx" rel="nofollow"&gt;https://hub.docker.com/_/nginx&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Build and run containers&lt;/h3&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/dcruz1990/django-misclientes"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
, ya ahí me despegué un poco de los tutoriales y ya tuve que incorporar un poco de CSS con MaterializeCSS. A pesar de que hay miles de soluciones open source al problema de llevar los clientes y contratos de una empresa, fue toda una experiencia. Eso fue aproximadamente en abril del 2019.

&lt;p&gt;También tuve la oportunidad de colaborar con un amigo en su blog personal, usando Asp Net Core y Angular. Y ayudar en su despliegue usando Docker y Nginx como proxy reverso. Otra maravillosa experiencia.&lt;/p&gt;

&lt;p&gt;Si has leído hasta aquí, pues esta es mi jornada bien resumida con la programación, muchas horas de desvelo debido a que en donde vivo el Internet era muy lento&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/dcruz1990" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vIuO59dg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--yWPcPY2d--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/111507/095f0ae9-aad7-409e-9260-482f5c5e99be.jpg" alt="dcruz1990"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/dcruz1990/what-would-be-the-best-night-time-to-code-274k" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;What would be the best night time to code?&lt;/h2&gt;
      &lt;h3&gt;Dennis Quesada Cruz ・ Feb 7 '20 ・ 1 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#discuss&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;-recientemente pusieron celdas LTE-, estados de ánimo cambiantes, altas/bajas en fin. La programación requiere mucho esfuerzo y dedicación, no es cosa de un día, aun así personalmente siento que he crecido mucho en este año 2020.&lt;/p&gt;

&lt;p&gt;Espero que tú también hayas tenido buenas experiencias en este, casi finalizado año 2020. ¿Podrías compartir algunas?&lt;/p&gt;

</description>
      <category>career</category>
      <category>motivation</category>
    </item>
    <item>
      <title>I have a infinite loading Dev.To index on my Android app.. why?</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Mon, 09 Mar 2020 16:00:25 +0000</pubDate>
      <link>https://dev.to/dcruz1990/i-have-a-infinite-loading-dev-to-index-on-my-android-app-why-507p</link>
      <guid>https://dev.to/dcruz1990/i-have-a-infinite-loading-dev-to-index-on-my-android-app-why-507p</guid>
      <description>&lt;p&gt;A few days ago I began to notice that the Dev.To Index in my Android app does not fully load, it stays there forever. I even checked that I had internet at a good speed. If I leave my account everything goes normal, I already uninstalled it several times and it does the same. Does anyone have any idea?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Lht6hXfG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/XszVCP5/Screenshot-20200309-110347.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Lht6hXfG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/XszVCP5/Screenshot-20200309-110347.jpg" alt="Broken Dev.To Index"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>help</category>
      <category>android</category>
    </item>
    <item>
      <title>What would be the best night time to code?</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Fri, 07 Feb 2020 02:55:32 +0000</pubDate>
      <link>https://dev.to/dcruz1990/what-would-be-the-best-night-time-to-code-274k</link>
      <guid>https://dev.to/dcruz1990/what-would-be-the-best-night-time-to-code-274k</guid>
      <description>&lt;p&gt;I have this situation, my full time job consumes most of the morning, so I have availability at night to work remotely, also at that time (much better at dawn) is when I have a better 3G connection.&lt;/p&gt;

&lt;p&gt;In your experience as developers, what would be the best practice, getting up at 2 am or going to bed a little later?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Can't change Kestrel default listening port when publishing.</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Wed, 29 Jan 2020 20:30:21 +0000</pubDate>
      <link>https://dev.to/dcruz1990/can-t-change-kestrel-default-listening-port-when-publishing-26o3</link>
      <guid>https://dev.to/dcruz1990/can-t-change-kestrel-default-listening-port-when-publishing-26o3</guid>
      <description>&lt;p&gt;Hello community, it turns out that I have an app with Netcore3.0 which I want to publish on a linux server. In my development environment, Kestrel works perfectly listening on port 5050, when it runs in the (local) production environment, it also listens on 5050.&lt;br&gt;
The problem is when it is &lt;strong&gt;published,&lt;/strong&gt; which somehow does not preserve the value of the established port, and starts listening to the default port.&lt;/p&gt;

&lt;p&gt;This is the command I use to publish:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;dotnet publish --configuration Release&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Apparently my environment variables are fine.&lt;/li&gt;
&lt;li&gt; I have checked the json file launchSettings and ensured that it is fine.&lt;/li&gt;
&lt;li&gt;I tried copying the appsettings jsons for the / bin / Release / netcoreapp3 / directory and it doesn't work.&lt;/li&gt;
&lt;li&gt;Tried adding &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Could you guide me in what other way I can change the default port of Kestrel or where else should I check again?&lt;/p&gt;

</description>
      <category>help</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Can't make a search on Dev.To :(  </title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Tue, 07 Jan 2020 18:36:14 +0000</pubDate>
      <link>https://dev.to/dcruz1990/can-t-make-a-search-on-dev-to-3bm1</link>
      <guid>https://dev.to/dcruz1990/can-t-make-a-search-on-dev-to-3bm1</guid>
      <description>&lt;p&gt;Every time I try to do a search here I get a blank screen, with the normal styles and menus of Dev.To but with nothing in the result .. same with the app on Android.&lt;br&gt;
Will it have something to do that I access from Cuba?&lt;/p&gt;

</description>
      <category>question</category>
      <category>devto</category>
    </item>
    <item>
      <title>Getting duplicated objetcs in ArrayList</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Thu, 06 Jun 2019 20:10:00 +0000</pubDate>
      <link>https://dev.to/dcruz1990/getting-duplicated-objetcs-in-arraylist-100o</link>
      <guid>https://dev.to/dcruz1990/getting-duplicated-objetcs-in-arraylist-100o</guid>
      <description>&lt;p&gt;Greetings community, it turns out that I have a job for the university, it's something very simple but I find it complex to achieve since I do not have much experience with Java.&lt;/p&gt;

&lt;p&gt;I have a list of objects in an ArrayList, I can add, delete and do other operations with that list using a "for each" loop. But I do not know how to count the objects on the list that are repeated. I have looked at some articles but they are with lists of integers as an example, where one can create another Array and iterate over both and compare the values of the positions.&lt;/p&gt;

&lt;p&gt;How would you proceed with an ArrayList of objects?&lt;/p&gt;

</description>
      <category>help</category>
      <category>java</category>
      <category>begginers</category>
      <category>schoolwork</category>
    </item>
    <item>
      <title>WeasyPrint impossible to install via PIP3</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Mon, 22 Apr 2019 16:04:41 +0000</pubDate>
      <link>https://dev.to/dcruz1990/weasyprint-impossible-to-install-via-pip3-1g77</link>
      <guid>https://dev.to/dcruz1990/weasyprint-impossible-to-install-via-pip3-1g77</guid>
      <description>&lt;p&gt;These days I was asking for help to deploy an ultra simple Django app, in the end I could not solve any of the paths that some friends suggested, so I decided to install the same OS that I have on the laptop in a virtual machine on the server waiting so that WeasyPrint did not give me problems.&lt;br&gt;
But the sad reality was again I could not install it, pip3 remains freezed although I executed the command with administrative permissions.&lt;br&gt;
This is a new package VM, just install python3-pip and all its dependencies (which are many).&lt;br&gt;
I find it curious that same thing happened to me with the Debian 9 container.&lt;br&gt;
What am I not doing? This already has me very badly the truth, it is something very simple that I have not been able to do. And the last thing I have left is to remove the functionality to my app to be able to export to PDF but that makes no sense. :(&lt;br&gt;
can anybody help me?&lt;/p&gt;

&lt;p&gt;I know it's something very basic and absurd but I do not know how to do it, sorry ...&lt;/p&gt;

&lt;p&gt;Here is the verbose:&lt;br&gt;
&lt;a href="https://thepracticaldev.s3.amazonaws.com/i/uzpbxcvarp7odvajqoyt.png"&gt;https://thepracticaldev.s3.amazonaws.com/i/uzpbxcvarp7odvajqoyt.png&lt;/a&gt;&lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>Help on Django Deployment</title>
      <dc:creator>Dennis Quesada Cruz</dc:creator>
      <pubDate>Sat, 20 Apr 2019 11:34:39 +0000</pubDate>
      <link>https://dev.to/dcruz1990/help-on-django-deployment-27le</link>
      <guid>https://dev.to/dcruz1990/help-on-django-deployment-27le</guid>
      <description>&lt;p&gt;For a little more than a month, I have been writing a simple app with Django to manage the client files in my company, I have Deepin operating system 15.9.&lt;br&gt;
As I am new I made the mistake of not creating a virtual env, so now when I try to deploy the app in a Debian 9 container, I have errors with WeasyPrint, cairocffi seems not to install at all ... despite getting the message of pip satisfactory when installing WeasyPrint.&lt;br&gt;
Then, tired and disappointed, I changed 2 views to the xhtml2pdf library, I also did not succeed because it showed an encoding error when using Latin-1, I tried to try UTf-8 and it get Unsuported Type error.&lt;br&gt;
On Monday I will try to install Deepin on the server and try with WeasyPrint again ...&lt;br&gt;
Any ideas to solve this ????&lt;/p&gt;

</description>
      <category>help</category>
      <category>begginers</category>
      <category>django</category>
      <category>deployment</category>
    </item>
  </channel>
</rss>
