<?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: Luis "shadowtampa" Gomes</title>
    <description>The latest articles on DEV Community by Luis "shadowtampa" Gomes (@vilailus).</description>
    <link>https://dev.to/vilailus</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%2F804594%2F5dde9128-3164-4d63-b75a-7eef688a2c6d.jpg</url>
      <title>DEV Community: Luis "shadowtampa" Gomes</title>
      <link>https://dev.to/vilailus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vilailus"/>
    <language>en</language>
    <item>
      <title>Redux Toolkit, managing states in React</title>
      <dc:creator>Luis "shadowtampa" Gomes</dc:creator>
      <pubDate>Sun, 18 Sep 2022 14:03:31 +0000</pubDate>
      <link>https://dev.to/vilailus/redux-toolkit-managing-states-in-react-267h</link>
      <guid>https://dev.to/vilailus/redux-toolkit-managing-states-in-react-267h</guid>
      <description>&lt;p&gt;React States. How do you manage them? When your application is quite small, it is okay (but not recomendable) to prop drill states. But when you have at least 5 different components or "grandson - grandfather" relationships, you need to have a solid management or your system will succumb.&lt;/p&gt;

&lt;h1&gt;
  
  
  What are my options?
&lt;/h1&gt;

&lt;p&gt;If you are dealing with small aplications, there is no shame on utilizing &lt;em&gt;useContext&lt;/em&gt;. It is actually quite interesting the fact that you can write your own hooks. The greatest thing about useContext is it simplicity. Write down a provider, a consumer and your hook, and you are all set. The only reason that I quit utilizing useContext was the Provider declaration. You need to wrap  your main div with a provider component and that really sucks when you have 4 or more hook necessities. What leads to our next option:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Redux Toolkit&lt;/em&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c7Y0fjm3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kljxcamfaaal5bx4e3wn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c7Y0fjm3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kljxcamfaaal5bx4e3wn.jpg" alt="Redux flow" width="880" height="495"&gt;&lt;/a&gt;&lt;br&gt;
Firt things first, dont be scaried. Altought redux is a frightening word, it use is fairly simple. You need only:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A store component&lt;/li&gt;
&lt;li&gt;A provider &lt;/li&gt;
&lt;li&gt;A slice&lt;/li&gt;
&lt;li&gt;A selector and a dispatcher&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Store Component
&lt;/h2&gt;

&lt;p&gt;The Redux store is the main component that makes all your &lt;em&gt;slices&lt;/em&gt; available for other components. Unlike useContext, you just need to wrap your main component with a single Provider. Think as a "switch".&lt;/p&gt;

&lt;h2&gt;
  
  
  Provider
&lt;/h2&gt;

&lt;p&gt;It is a component that you will wrap the main component or your application. It is only required once. That is the way that you are going to utilize the Store Component&lt;/p&gt;

&lt;h2&gt;
  
  
  Slice
&lt;/h2&gt;

&lt;p&gt;Probaly you are wondering "what the heck is a slice?". A slice is your command center for managing a state. In simple backends you have a controller. A slice is nothing more than a Slice. In this component you are able to receive requests, alter states, fetch results from state and mutate then, both sync and async. For that, you'll need reducers, that are analogue to Controller methods. Sou you can have a "create reducer", a "update", and so, untill you have a CRUD. &lt;/p&gt;

&lt;h2&gt;
  
  
  selector and a dispatcher
&lt;/h2&gt;

&lt;p&gt;Okay, you did set up your application, but how you fetch and mutate data in your components? Trough selectors and dispatchers. Selector is the way you are going to fetch data (both the whole state or destructure some props) and Dispatcher is the mutators of the data, the way you are going to utilize the CRUD reducers, for instance. &lt;/p&gt;

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

&lt;p&gt;Redux Toolkit is the way to go for your applications, since you dont want to be stuck with multi-providing or prop drilling issues. So, dont be afraid, take a read on &lt;a href="https://redux-toolkit.js.org/introduction/getting-started"&gt;https://redux-toolkit.js.org/introduction/getting-started&lt;/a&gt; and fire on this trouble!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Set theory(with PHP)</title>
      <dc:creator>Luis "shadowtampa" Gomes</dc:creator>
      <pubDate>Thu, 10 Feb 2022 17:41:01 +0000</pubDate>
      <link>https://dev.to/vilailus/set-theorywith-php-4bec</link>
      <guid>https://dev.to/vilailus/set-theorywith-php-4bec</guid>
      <description>&lt;p&gt;Heres a Cheat Sheet I made for joins! Also, here are some PHP 8 examples with sets. It&lt;code&gt;s important to master the basics, because in the future you&lt;/code&gt;ll spend less time trying to build workarounds for simple solutions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mLIqyHYs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e48526pg3aoybjt4mr1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mLIqyHYs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e48526pg3aoybjt4mr1l.png" alt="Image description" width="880" height="880"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;`&amp;lt;?php&lt;/p&gt;

&lt;p&gt;$array_a = [1,2,3,4,5];&lt;br&gt;
$array_b = [2,3,4,5,6];&lt;/p&gt;

&lt;p&gt;function left_excluding_join($left, $right) {&lt;br&gt;
    return array_diff($left, $right);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;function left_outer_join($left, $right) {&lt;br&gt;
    return $left;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;function right_excluding_join($left, $right) {&lt;br&gt;
    return array_diff($right, $left);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;function right_outer_join($left, $right) {&lt;br&gt;
    return $right;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;function full_join($left, $right) {&lt;br&gt;
    return array_unique(array_merge($left, $right));&lt;br&gt;
}     &lt;/p&gt;

&lt;p&gt;function inner_join($left, $right) {&lt;br&gt;
    return array_intersect($left, $right);&lt;br&gt;
}  &lt;/p&gt;

&lt;p&gt;function outer_excluding_join($left, $right) {&lt;br&gt;
    return array_diff(full_join($left, $right), inner_join($left, $right));&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
echo "=== LEFT EXCLUDING JOIN ===\n";&lt;br&gt;
print_r (left_excluding_join($array_a, $array_b));&lt;/p&gt;

&lt;p&gt;echo "=== LEFT OUTER JOIN ===\n";&lt;br&gt;
print_r (left_outer_join($array_a, $array_b));&lt;/p&gt;

&lt;p&gt;echo "=== RIGHT EXCLUDING JOIN ===\n";&lt;br&gt;
print_r (right_excluding_join($array_a, $array_b));&lt;/p&gt;

&lt;p&gt;echo "=== RIGHT OUTER JOIN ===\n";&lt;br&gt;
print_r (RIGHT_outer_join($array_a, $array_b));&lt;/p&gt;

&lt;p&gt;echo "=== FULL JOIN ===\n";&lt;br&gt;
print_r (full_join($array_a, $array_b));&lt;/p&gt;

&lt;p&gt;echo "=== INNER JOIN ===\n";&lt;br&gt;
print_r (inner_join($array_a, $array_b));&lt;/p&gt;

&lt;p&gt;echo "=== OUTER EXCLUDING JOIN ===\n";&lt;br&gt;
print_r (outer_excluding_join($array_a, $array_b));&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;And the results:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;=== LEFT EXCLUDING JOIN ===&lt;br&gt;
Array&lt;br&gt;
(&lt;br&gt;
    [0] =&amp;gt; 1&lt;br&gt;
)&lt;br&gt;
=== LEFT OUTER JOIN ===&lt;br&gt;
Array&lt;br&gt;
(&lt;br&gt;
    [0] =&amp;gt; 1&lt;br&gt;
    [1] =&amp;gt; 2&lt;br&gt;
    [2] =&amp;gt; 3&lt;br&gt;
    [3] =&amp;gt; 4&lt;br&gt;
    [4] =&amp;gt; 5&lt;br&gt;
)&lt;br&gt;
=== RIGHT EXCLUDING JOIN ===&lt;br&gt;
Array&lt;br&gt;
(&lt;br&gt;
    [4] =&amp;gt; 6&lt;br&gt;
)&lt;br&gt;
=== RIGHT OUTER JOIN ===&lt;br&gt;
Array&lt;br&gt;
(&lt;br&gt;
    [0] =&amp;gt; 2&lt;br&gt;
    [1] =&amp;gt; 3&lt;br&gt;
    [2] =&amp;gt; 4&lt;br&gt;
    [3] =&amp;gt; 5&lt;br&gt;
    [4] =&amp;gt; 6&lt;br&gt;
)&lt;br&gt;
=== FULL JOIN ===&lt;br&gt;
Array&lt;br&gt;
(&lt;br&gt;
    [0] =&amp;gt; 1&lt;br&gt;
    [1] =&amp;gt; 2&lt;br&gt;
    [2] =&amp;gt; 3&lt;br&gt;
    [3] =&amp;gt; 4&lt;br&gt;
    [4] =&amp;gt; 5&lt;br&gt;
    [9] =&amp;gt; 6&lt;br&gt;
)&lt;br&gt;
=== INNER JOIN ===&lt;br&gt;
Array&lt;br&gt;
(&lt;br&gt;
    [1] =&amp;gt; 2&lt;br&gt;
    [2] =&amp;gt; 3&lt;br&gt;
    [3] =&amp;gt; 4&lt;br&gt;
    [4] =&amp;gt; 5&lt;br&gt;
)&lt;br&gt;
=== OUTER EXCLUDING JOIN ===&lt;br&gt;
Array&lt;br&gt;
(&lt;br&gt;
    [0] =&amp;gt; 1&lt;br&gt;
    [9] =&amp;gt; 6&lt;br&gt;
)&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>logic</category>
      <category>set</category>
      <category>sheet</category>
    </item>
    <item>
      <title>CORS: Explaining with food.</title>
      <dc:creator>Luis "shadowtampa" Gomes</dc:creator>
      <pubDate>Thu, 27 Jan 2022 13:07:54 +0000</pubDate>
      <link>https://dev.to/vilailus/cors-explaining-with-food-122</link>
      <guid>https://dev.to/vilailus/cors-explaining-with-food-122</guid>
      <description>&lt;p&gt;CROSS-ORIGIN Resource Sharing is a policy for requesting information from a source different than yours, going against the standart same-origin policy in most of the browsers. Picture yourself having food at your home. That delicious meat that your mother cooks that is, hhhmmm, delicous, and you believe in her hands, because you know she cleans her hands, she bathes: same-origin provides you safety. But I doubt that your mom can cook a milk shake and a Big Mac in less than 5 minutes. So you order food, and unless you live inside a MCdonalds, the delivery will come from a different origin. But you know if the cooker has knowledge of ... soap? If he actually cleans his hands? Not same origin, or shorten, cross-origin is dangerous most of the times. Thats why your browser locks it up.&lt;br&gt;
For further and better reading, have this link: &lt;a href="https://web.dev/cross-origin-resource-sharing/"&gt;https://web.dev/cross-origin-resource-sharing/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>http</category>
      <category>api</category>
      <category>laravel</category>
      <category>backend</category>
    </item>
    <item>
      <title>College and Code</title>
      <dc:creator>Luis "shadowtampa" Gomes</dc:creator>
      <pubDate>Thu, 27 Jan 2022 12:52:09 +0000</pubDate>
      <link>https://dev.to/vilailus/college-and-code-54oo</link>
      <guid>https://dev.to/vilailus/college-and-code-54oo</guid>
      <description>&lt;p&gt;Are you in college? That is one of the best opportunities that you will ever have... for social skills. College is not a place to learn to code. In fact, is the hotspot for networking. The biggest mistake I made back in 2017 when I entered college was the false notion that I would become the "hackerman" as soon as I entered the college... But for sure I made friends. Still do. If theres a hot tip for college newbies, it would be: learn to be a self-taught, self-sufficient machine of advancements. Then, and only then, college will begin to help you. &lt;/p&gt;

</description>
      <category>college</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
