<?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: Murphydhee</title>
    <description>The latest articles on DEV Community by Murphydhee (@murphydhee).</description>
    <link>https://dev.to/murphydhee</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%2F562187%2F027fa74a-8fd3-4b03-86b4-534a355b4c79.jpg</url>
      <title>DEV Community: Murphydhee</title>
      <link>https://dev.to/murphydhee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/murphydhee"/>
    <language>en</language>
    <item>
      <title>The use of Vue Use State Effect as an alternative to Vuex and Pinia.</title>
      <dc:creator>Murphydhee</dc:creator>
      <pubDate>Tue, 15 Aug 2023 22:45:58 +0000</pubDate>
      <link>https://dev.to/murphydhee/the-use-of-vue-use-state-effect-as-an-alternative-to-vuex-and-pinia-1a6g</link>
      <guid>https://dev.to/murphydhee/the-use-of-vue-use-state-effect-as-an-alternative-to-vuex-and-pinia-1a6g</guid>
      <description>&lt;p&gt;In the dynamic world of Vue.js, state management has been a pivotal challenge. Vuex, the stalwart solution, has served us well with its versatility and extensive capabilities. However, as applications grew, the need for a more lightweight and less complex alternative arose. With Vue 3's Composition API, a new era dawned, allowing developers to rethink state management, this gave birth to Pinia.&lt;/p&gt;

&lt;p&gt;A Breath of Fresh Air you could say as Pinia, a powerful and intuitive state management solution that emerged from the desire to simplify and optimize Vuex's complex ecosystem. Pinia integrates seamlessly with Vue 3's Composition API, presenting developers with a streamlined alternative. By eliminating the need for mutations, commits, and data dispatching, Pinia offers a minimalistic approach to the way to state management. Its simplicity doesn't compromise on versatility, making it a refreshing choice for modern Vue applications.&lt;/p&gt;

&lt;p&gt;Composables: The Composition API's Hidden Gem Vue 3's Composition API introduces a game-changing concept known as EffectScope. This innovative feature records all effects created during a component's lifecycle, including computed properties. What sets EffectScope apart is its ability to be shared across the application, facilitating the attachment of additional data. &lt;/p&gt;

&lt;p&gt;Empowering Developers with Vue Use State Effect library. The Vue Use State Effect harnesses the power of EffectScope to bring a new level of control and flexibility to state management. By encapsulating composable states, it provides a seamless sharing mechanism across different components. This approach eliminates the need for unnecessary abstractions, letting developers create custom logic while retaining the innate development flow. The era of unwieldy state management solutions is fading, replaced by tailored approaches that align with Vue 3's ethos. With these tools at your disposal, you can create applications that are not only efficient but also optimized for the modern web landscape.&lt;/p&gt;

&lt;p&gt;And that's how and why the vue-state-effect library was created. with it as your arsenal, you can shape the composable however you want to share can be wrapped and joined. Used in the other components afterwards. Finally, without any additional abstraction, you can use it to create sharable states/stores inside your application - handling them via composables with your own custom logic. Still, kepping alive the native-like flow of the development. Awesome right? &lt;/p&gt;

&lt;p&gt;To tackle data stacking, it provides us with Destroy utility to avoid data stacking whenever you want.&lt;/p&gt;

&lt;p&gt;To kick start the process you will have to &lt;a href="https://www.npmjs.com/package/vue-use-state-effect"&gt;install&lt;/a&gt; the the Vue-use-state-effect&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* composables/useSharedState.ts */

import { ref } from 'vue'

const sharedState = () =&amp;gt; {
  const state = ref({
    test: ' First state value.',
  })
  const updateState = () =&amp;gt; {
    state.value = {
      test: ' Updated state value.',
    }
  }
  return {
    state,
    updateState,
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is to import the vue-use-state-effect and use it with our newly created composable. Notice that this is done in the same file/component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* composables/useSharedState.ts */

import { useStateEffect } from 'vue-use-state-effect'

/* your composable logic goes here  */

export const useSharedState: any = useStateEffect(sharedState, {
  name: 'sharedState',
  debug: true,
  destroy: false,
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we’ve just created the shared composable, we can move along with our components. Let’s create one and check how we can use it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- Landing Page | landing.vue --&amp;gt;

&amp;lt;template&amp;gt;
  &amp;lt;div&amp;gt;{{ test Component }}&amp;lt;/div&amp;gt;
  &amp;lt;button @click="updateState"&amp;gt;Update the state&amp;lt;/button&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script setup lang="ts"&amp;gt;
import { computed } from 'vue'
import { useSharedState } from '@composables/useSharedState'

const {
  sharedState: { state, updateState },
} = useSharedState()

const test = computed(() =&amp;gt; state.value.test) // 'First state value.',
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the code snippet above you can see that we import the state/store data from the composable. The parent object key is defined on top of the name provided within the composable. Making use of the computed property to create the reactive one to reflect it in the template. In addition to that we passed the update method through the use of the button to update the state from the UI. Now we can create a new page to render the updated state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- New Page | newPage.vue --&amp;gt;

&amp;lt;template&amp;gt;
  &amp;lt;div&amp;gt;{{ test component }}&amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script setup lang="ts"&amp;gt;
import { ref } from 'vue'
import { useSharedState } from '@composables/useSharedState'

const {
  sharedState: { state },
} = useSharedState()
const test = ref(state.value.test) // 'Updated state value.',
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The power is now in your hands. With this knowledge, you're equipped to wield your shared state (composable) seamlessly throughout your application. And should you wish to ensure a tidy application lifecycle, the destroy option stands ready to declutter your data. &lt;/p&gt;

&lt;p&gt;Here's a quick pro-tip: in scenarios involving asynchronously rendered components, in the cases of Nuxt, the onMounted hook comes to your aid, enabling you to reclaim your reconstructed state. The journey to exploring state management has taken an even more intriguing turn!&lt;/p&gt;

&lt;p&gt;Back to our New page&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- New Page | newPage.vue --&amp;gt;

&amp;lt;script setup lang="ts"&amp;gt;
import { onMounted } from 'vue'

const test = ref('')

onMounted(() =&amp;gt; {
  const {
    sharedState: { state },
  } = useSharedState()
  test.value = state.value.test
})
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to the most important question I am guessing has been on the back of your mind since the start of this article.&lt;/p&gt;

&lt;p&gt;Are there any downsides to what might seem like the ultimate tool? I know it seems too good to be true but Yes! Due to its simplicity, you won't experience the same structured format and flow as seen in Pinia or Vuex. Additionally, it won't be visible in dev tools. However, there's a debug mode that can serve as a reasonable alternative. You might encounter other limitations as well, as it's not a one-size-fits-all solution for every project. Finding the right balance is key.&lt;/p&gt;

&lt;p&gt;Simplistic and primal, everything more and a little less when it comes to the majority of small Vue apps. I recommend it as it might be the best, fastest, and most convenient solution. Just give it a try, now or with your next project and let me know how it goes in the comments.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Beginner's Guide: Setting Up a CI/CD Pipeline for Your Frontend Project with GitLab CI/CD</title>
      <dc:creator>Murphydhee</dc:creator>
      <pubDate>Sun, 13 Aug 2023 02:32:43 +0000</pubDate>
      <link>https://dev.to/murphydhee/a-beginners-guide-setting-up-a-cicd-pipeline-for-your-frontend-project-with-gitlab-cicd-34l4</link>
      <guid>https://dev.to/murphydhee/a-beginners-guide-setting-up-a-cicd-pipeline-for-your-frontend-project-with-gitlab-cicd-34l4</guid>
      <description>&lt;p&gt;In the current world of software development, having a super helper that checks your code and even delivers it to users in real-time. CI/CD are like your trusty assistants making sure your code is great and gets to users fast. CI/CD known as Continuous Integration and Continuous Deployment (CI/CD) pipelines automate the process of testing, building, and deploying code, ensuring that your application is always in its best shape. In this beginner-friendly guide, I will walk you through setting up a CI/CD pipeline for your front-end project using GitLab CI/CD.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding CI/CD: A Quick Overview
&lt;/h3&gt;

&lt;p&gt;Continuous Integration (CI) as the name implies means continually making code changes that are being integrated into a shared repository. This ensures that all code changes are automatically validated by automated builds and tests. However, on the other hand, Continuous Deployment (CD) automates the release of validated code to production safely sending your checked code to users so they can enjoy it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Creating a GitLab Repository
&lt;/h3&gt;

&lt;p&gt;To begin, create a GitLab repository for your front-end project. If you're new to GitLab, &lt;a href="https://gitlab.com/users/sign_up" rel="noopener noreferrer"&gt;sign up&lt;/a&gt; for an account, and then follow the prompts to create a new repository. Once your repository is ready, you can either upload your existing code or clone an empty repository to your local machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Writing Tests
&lt;/h3&gt;

&lt;p&gt;Before diving into the CI/CD setup, ensure you have a suite of tests for your front-end project. These tests will help catch bugs early in the development process. Frameworks like Jest, Mocha, Cypress or Jasmine can be used for writing tests, depending on your project's technology stack.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Creating a &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; File
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file is where you define your CI/CD pipeline stages and jobs. This file lives in the root directory of your repository. Here's a basic example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;

&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;npm install&lt;/span&gt;

&lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;npm test&lt;/span&gt;

&lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;npm run build&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have three stages: &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;test&lt;/code&gt;, and &lt;code&gt;deploy&lt;/code&gt;. GitLab will automatically run jobs in these stages whenever you push new code to your repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: GitLab CI/CD Setup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Navigate to CI/CD Settings&lt;/strong&gt;: In your GitLab repository, go to "Settings" &amp;gt; "CI/CD".&lt;/li&gt;
&lt;/ol&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn3zngzn66tv6fi3rz3g1.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn3zngzn66tv6fi3rz3g1.png" alt="Navigate to CI/CD"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Runner Configuration&lt;/strong&gt;: Choose whether you want to use shared runners or your runners. Runners are responsible for executing your CI/CD jobs.&lt;/li&gt;
&lt;/ol&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyi7d6e8zbdsdmalpt7z.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyi7d6e8zbdsdmalpt7z.png" alt="Set up runner configuration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Auto DevOps&lt;/strong&gt;: GitLab offers an Auto DevOps feature that can automatically detect, build, test, and deploy your project based on common practices. For beginners, this can be a great starting point.&lt;/li&gt;
&lt;/ol&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F882an0xf203wf8qwapc3.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F882an0xf203wf8qwapc3.png" alt="enable Auto DevOps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Monitoring Your Pipeline
&lt;/h3&gt;

&lt;p&gt;With your CI/CD pipeline set up, GitLab will automatically trigger jobs whenever you push code changes. You can monitor the progress and results of your pipeline in the "CI/CD" section of your GitLab repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Setting up a CI/CD pipeline might seem intimidating at first, but with tools like GitLab CI/CD, it becomes a manageable task. By automating the testing and deployment process, you'll save time, reduce errors, and ensure your front-end project is of the highest quality when it reaches your users. &lt;/p&gt;

&lt;p&gt;Remember, this article is an introductory guide. As you become more comfortable with CI/CD, you can explore advanced features like environment variables, deployment strategies. I will cover these in a subsequent article.&lt;/p&gt;

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