teleren/devto huggingface dataset:
How I Discovered to Not Put EventListeners in On Mount in Vue SPAs
Tags: vue, javascript, router, events
Published: 2024-04-30 10:19:05

---
title: How I Discovered to Not Put EventListeners in On Mount in Vue SPAs

published: true
description: Simple proof-of-concept that shows how I discovered that eventlisteners stack doesn't clean itself switching routes in vue router
tags: vue, javascript, router, events

# published_at: 2024-04-30 12:18 +0000
---

## Introduction

During a project for a client, I was tasked with integrating an event listener within a Vue-based Single Page Application (SPA), specifically for a component named "HomeView" that contained an iframe. The event, dubbed "triggerEvent," was initially set up during the 'onMount' lifecycle hook of HomeView. This setup led to unexpected behavior where navigating away and then returning to HomeView caused the "triggerEvent" to fire multiple times, indicating a stacking of event listeners.

## Investigating the Issue

To understand the issue better, I experimented with `location.replace()` instead of `router.push()` for navigation. The former seemed to resolve the issue, suggesting that the method of navigation affected how event listeners behaved. Further tests with `router.push()` confirmed that each navigation added a new listener without removing the previous one, thereby multiplying the triggers.

## The Root Cause

This behavior is rooted in how SPA frameworks like Vue manage event listeners. In Vue, components mounted with `onMount` do not automatically clean up their event listeners upon unmounting unless explicitly coded to do so. This leads to duplicated listeners if a component mounts multiple times, as is common in SPAs where `router.push()` is used for navigation without full page reloads.

## Solutions

### Cleanup on Component Unmount

To prevent this issue, one effective strategy is to remove event listeners when the component unmounts:

```javascript
import { onMounted, onUnmounted } from 'vue';

export default {
  setup() {
    const handleEvent = () => console.log('Event triggered');
    onMounted(() => window.addEventListener('triggerEvent', handleEvent));
    onUnmounted(() => window.removeEventListener('triggerEvent', handleEvent));
  }
};
```

### Conditional Event Listener Attachment

Alternatively, checking if an event listener is already in place before adding a new one can prevent duplicates:

```javascript
import { onMounted, ref } from 'vue';

const eventBound = ref(false);

export default {
  setup() {
    const handleEvent = () => console.log('Event triggered');
    onMounted(() => {
      if (!eventBound.value) {
        window.addEventListener('triggerEvent', handleEvent);
        eventBound.value = true;
      }
    });
  }
};
```

### Global Event Listener in App.vue

Another approach is to place the event listener in `App.vue`, which is only mounted once, thereby avoiding any reattachment issues:

```javascript
import { onMounted } from 'vue';

export default {
  setup() {
    const handleEvent = () => console.log('Global event triggered');
    onMounted(() => window.addEventListener('triggerEvent', handleEvent));
  }
};
```
Developing .NET Inside a devcontainer
Tags: devcontainer, dotnet, intellisense, interactive
Published: 2024-04-30 10:18:42

I really love devcontainers in VS Code! The whole concept that you can define an entire dev environment using just a json file is quite amazing.

Daily, I'm developing .NET applications using C# and sometimes F#.

Here is how you can get an environment up and running in no time - with IntelliSense working!

_devcontainer.json_

```
{
    "name": "f-sharp-playground",
    "build":{
        "dockerfile": "Dockerfile"
    },
    "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces,type=bind",
    "workspaceFolder": "/workspaces",
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-dotnettools.csharp",
                "ms-dotnettools.csdevkit",
                "ms-dotnettools.dotnet-interactive-vscode",
                "jebbs.plantuml",
                "Ionide.Ionide-fsharp",
                "ms-dotnettools.vscode-dotnet-runtime"
            ]
        }
    }
}
```
_Dockerfile_

```
FROM mcr.microsoft.com/dotnet/sdk:8.0

# E.g. add dotnet tools here:
# RUN dotnet tool install --global dotnet-format

```

**How to fix the problem with IntelliSense**

If you didn't add `workspaceMount` and `workspaceFolder` you can find the course of IntelliSenses crash here:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cnsbadek0qdfusmrah1c.png)

**Be patient!**

Every time the container rebuilds it takes most of 30 sec to install everything.

Enjoy :)
Tempo Traveller Hire Delhi
Tags: best
Published: 2024-04-30 10:18:03


If you're looking for luxury Tempo Traveller hire in Delhi, you're likely seeking a premium travel experience with added comfort, amenities, and convenience, You may hire[ Sarthi India Travels](https://sarthiindiatravels.com/luxury-tempo.php
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whmt6waxkurbsk2t4a9u.jpg)) they provide best luxury tempo traveller service in Delhi. Here are some steps you can take to find luxury Tempo Traveller rental services in Delhi:

Online Search: Use search engines or online travel platforms to find luxury Tempo Traveller rental services in Delhi. Look for companies that specialize in premium travel experiences and offer upscale vehicles with added amenities.
Read Reviews: Once you find potential rental companies, read reviews from past customers to gauge their satisfaction with the service, vehicle quality, and overall experience. Websites like TripAdvisor, Google Reviews, or specialized travel forums can be helpful for this purpose.
Check Websites and Portals: Visit the websites of rental companies or travel portals that offer luxury Tempo Traveller hire services in Delhi. Look for detailed information about the vehicles available, amenities offered, pricing, and booking process.
Compare Options: Compare the features, amenities, pricing, and terms of different rental companies to find the best fit for your needs and budget. Pay attention to factors such as vehicle condition, interior comfort, entertainment options, and additional services provided.
Contact Rental Companies: Reach out to the rental companies directly to inquire about availability, pricing, and any special requirements or preferences you may have. Ask about customization options and any additional services they offer, such as chauffeur service, onboard refreshments, or tour packages.
Book in Advance: Once you've chosen a rental company and vehicle, book your luxury Tempo Traveller rental well in advance to secure your reservation, especially during peak travel seasons or for special events. Make sure to confirm the booking details and any special requests before finalizing your reservation.
By following these steps and conducting thorough research, you can find a reliable and reputable luxury Tempo Traveller rental service in Delhi that meets your expectations for a comfortable and enjoyable travel experience.
https://sarthiindiatravels.com/luxury-tempo.php
Integrating Firebase with Next.js for Static Generation
Tags: javascript, react, nextjs, firebase
Published: 2024-04-30 10:00:53


At [itselftools.com](https://itselftools.com), we've developed over 30 projects utilizing the powerful combination of Next.js and Firebase. These technologies allow us to build fast, scalable, and dynamic applications effectively. In this tutorial, we'll take a closer look at how to use Firebase Firestore together with Next.js's `getStaticProps` to enhance your web applications by pre-rendering data fetched at build time.

## Exploring the Code

Here's a concise breakdown of the code snippet that integrates Firebase with Next.js:

```js
import { useEffect } from 'react';
import firebase from '../firebase/clientApp';

export async function getStaticProps() {
  const db = firebase.firestore();
  const data = await db.collection('items').get();
  const items = data.docs.map(doc => doc.data());
  return { props: { items } };
}

function HomePage({ items }) {
  useEffect(() => {
    // Perform client-side operations
  }, []);
  return (
    <div>
      {items.map(item => (
        <div key={item.id}>{item.name}</div>
      ))}
    </div>
  );
}

export default HomePage;
```

### Breakdown
- **Firebase Integration**: The code begins by importing Firebase and configuring Firestore. `getStaticProps` fetches data from the 'items' collection in Firestore at build time. This approach is particularly beneficial for performance since the data is fetched once during the build and served statically on each request.
- **Mapping Firestore Documents**: Once fetched, the Firestore documents are converted to a JavaScript array containing the items' details, ready to be used in our React component.
- **React Component and useEffect**: In the `HomePage` component, items are displayed using a map function. Although this example doesn't utilize `useEffect` for specific operations, it's setup to enable adding client-side JavaScript that interacts with the DOM or performs additional effects post-render.

## Why Use getStaticProps?
Using `getStaticProps` in Next.js applications allows you to pre-render pages with the data fetched at build time, which reduces the load on your server and can improve load times significantly for your users. It's an ideal strategy for pages where the data changes infrequently and is suitable for SEO as the pre-rendered page can be easily indexed by search engines.

## Conclusion
The integration of Firebase with Next.js opens up a plethora of possibilities for developers aiming to create optimized web applications. If you're excited to see real-world applications of such integrations, check out our tools such as [Find Rhyming Words](https://rhymes-with.com), [Discover Your Location](https://my-current-location.com), and [Text Extraction Tool](https://ocr-free.com). These applications utilize similar technologies and can provide insights into practical implementations of complex features.

We hope this tutorial helps you understand how to combine Firebase and Next.js effectively in your projects. For more useful coding tips and guides, continue exploring itselftools.com!
Write for us marketing
Published: 2024-04-30 09:53:29

Join our dynamic community and showcase your expertise by writing for us! We are always on the lookout for talented writers to contribute engaging and insightful content on topics related to [write for us marketing](https://techobusiness.com/write-for-us/). Whether you're a seasoned marketer, a budding entrepreneur, or an industry expert, we welcome your unique perspective. Share your knowledge, expand your reach, and connect with a global audience through our platform. Submit your articles today and become a part of our vibrant marketing community!
Vision AI agents for any task
Tags: ai, machinelearning, python, computervision
Published: 2024-04-30 09:52:57

After spending some months working on the [Pipeless open-source framework](https://github.com/pipeless-ai/pipeless), today I bring something new and really cool: [Pipeless Agents](https://agents.pipeless.ai)

![Pipeless Agents Annoucement](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/273v7d3qbg22wh1p8z15.png)

Imagine providing a video source and directly processing a data stream that represents what is happening on the video, just like when you work with normal data. Each payload represents an event on the video, an object, or whatever you are interested in.

Sounds good, right? Well, it is now possible.

With [Pipeless Agents](https://agents.pipeless.ai) you can **create any kind of automation based on real-time video inputs**. You do not need infrastructure, you do not need to label data or train models. You connect a git repository with your agent logic and the rest is handled for you.

## So, what does that agent logic look like?

It is just a script that processes the data extracted from your video sources, like the following:

![Pipeless Agents agent code example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3xmgsj00om0dh4t9oph.png)

As you can see, **with just two lines of code** you can define the agent. The first imports the SDK and the second is a for loop that will run for every data structure extracted from the video. Inside the loop, you can do whatever you want. You can send emails or Slack notifications, you can call some webhooks, you can stop a production line, you can analyze and store the data in a database, ... There are no restrictions, **the only limit is your imagination**! 

## But, how does the agent know the kind of data/events you want?

We use some filters for that. Every filter focuses on exporting specific data or detecting a specific event. When you connect your video sources you also specify the list of filters that you want to apply to the video and every filter produces a well-defined data structure, which is what your agent receives.

Right now, we are providing some pre-defined filters such as object detection, but we are working to allow you to define your custom filters. Let us know if there is some specific filter you would like to see!

## How do you get started?

Just go to https://agents.pipeless.ai and create your first agent!
Also don’t forget to send us your feedback, we love to hear your thoughts!

Hope you enjoy it!
How to create a custom node in reactflow
Tags: reactflow, react, webdev, javascript
Published: 2024-04-30 09:49:18


![Custom node using reactflow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mew1k2frm5dpmb1tv4od.png)
In this post I will walk you through how to create a custom node using reactflow.

Few days back, I decided to build a flow builder using reactflow as part of a frontend coding challenge. It was my first time playing around with reactflow and I struggled a bit to create a custom node using the same. 

If you are trying to figure out how to create a custom node using reactflow, this post is for you.

I am assuming you know how to setup a react project and to install reactflow. (feel free to refer [this](https://vitejs.dev/guide/) page to understand how to create a new react project using vite).

Follow the below steps to create a custom node

- Create a new component, lets give it a name CustomNode

```
import { Handle, Position } from "reactflow";
import { BiMessageRoundedDetail } from "react-icons/bi";
import { BiLogoWhatsapp } from "react-icons/bi";
import "../assets/styles/CustomNode.css";

export const CustomNode = ({ data }) => {
  return (
    <div className="custom-node">
      <Handle type="target" position={Position.Left} id="target" />
      <div className="custom-node__header">
        <div>
          <BiMessageRoundedDetail />
          <div className="custom-node__title">Send message</div>
        </div>
        <div className="custom-node__whatsapp-icon">
          <BiLogoWhatsapp />
        </div>
      </div>
      <div className="custom-node__text">{data?.label}</div>
      <Handle type="source" position={Position.Right} id="source" />
    </div>
  );
};

```
Style the component according to your requirement. 

- Keep a constant variable nodeTypes and set the value as  follows `const nodeTypes = { textUpdater: CustomNode };`

here, replace `textUpdater` with the name of your choice.
`CustomNode` is the component we have created previously. 

- Pass the nodeTypes to `ReactFlow` component along with the other values

```
<ReactFlow
 nodes={nodes}
 edges={edges}
 onNodesChange={onNodesChange}
 onEdgesChange={onEdgesChange}
 onConnect={onConnect}
 onInit={setReactFlowInstance}
 onDrop={onDrop}
 onDragOver={onDragOver}
 onNodeClick={onNodeClick}
 nodeTypes={nodeTypes}
 fitView           
/>
```

With this changes, you will be able to see your custom node in action..


Feel free to comment or reach out to me if you face issues dealing with custom nodes or reactflow, I will be more than happy to help! Cheers.
What are the top benefits of an AI development company?
Tags: aidevelopmentcompany, aidevelopmentservices, aiappdevelopmentcompany
Published: 2024-04-30 09:47:45

An AI development company can offer a range of benefits, depending on their expertise and focus.

##Here are some of the top benefits of an AI development company:

##Expertise:

AI development companies typically have a team of skilled professionals with expertise in various AI technologies, including machine learning, natural language processing, computer vision, and more. This expertise allows them to develop advanced AI solutions tailored to specific needs.

##Innovation:

AI development companies are at the forefront of technological innovation. They stay updated with the latest advancements in AI research and apply them to create cutting-edge solutions that can give businesses a competitive edge.

##Customization:

AI development companies can tailor solutions to meet the unique requirements of businesses across different industries. Whether it's developing recommendation systems for e-commerce platforms or predictive maintenance solutions for manufacturing companies, they can customize AI applications to fit specific needs.

##Scalability:

AI development companies can build scalable solutions that can grow with the business. Whether you're a startup looking to pilot a new AI application or a large enterprise seeking to deploy AI across multiple departments, they can design solutions that scale according to your needs.

##Cost-effectiveness:

Outsourcing AI development to a specialized [AI development company](https://www.nextbraintech.com/ai-artificial-intelligence-app-development-company) can often be more cost-effective than hiring an in-house team. AI development companies already have the necessary infrastructure and expertise in place, saving businesses the time and resources required to build an internal AI team from scratch.

##Focus on Core Business Activities:

By partnering with an AI development company, businesses can focus on their core activities while leaving the AI development and maintenance tasks to the experts. This allows companies to allocate resources more efficiently and concentrate on their strategic objectives.

##Continuous Support and Maintenance:

[AI development services](https://www.nextbraintech.com/ai-artificial-intelligence-app-development-company) typically provide ongoing support and maintenance services to ensure that AI solutions continue to perform optimally over time. This includes monitoring performance, troubleshooting issues, and implementing updates or improvements as needed.

##Conclusion:

Overall, partnering with an AI development company can accelerate the development and deployment of AI solutions, allowing businesses to leverage the power of AI to drive innovation, improve efficiency, and achieve their business objectives.
Decorative premium quality cushion covers | Monstera Hut
Tags: decorativepremiumquality, cushioncovers, monsterahut
Published: 2024-04-30 09:44:12

Indulge in elegance and sophistication with Monstera Hut in Noida. Elevate your home decor with our exquisite Spring Bloom Floral Beaded Cushion Cover, designed to add a touch of luxury to any space. Our **[decorative premium quality cushion covers](https://monsterahut.in/shop/cushion-covers)** are crafted with precision and attention to detail, ensuring both style and comfort. Embrace the beauty of intricate floral beadwork and transform your living room into a haven of refinement. At Monstera Hut, we believe in enhancing every aspect of your living experience, from the smallest details to the grandest designs. Explore our collection of decorative premium quality cushion covers and discover the perfect accent for your home decor in Noida.
OT technician course fees
Tags: otcours, ottechnicalcour, otcoursefees
Published: 2024-04-30 09:41:31

The fees for an Operating Theatre (OT) Technician course can vary depending on factors such as the institution offering the course, its location, duration, and the specific curriculum provided. Additionally, fees may differ between public and private institutions.

As of my last update, which was in January 2022, the fees for an OT Technician course in India ranged from approximately ₹20,000 to ₹1,00,000 or more for the entire duration of the course. However, these figures are approximate and may have changed since then.

It's essential to research and contact the institutions directly to get accurate and up-to-date information about the course fees, as well as any additional costs such as registration fees, exam fees, and materials. Additionally, inquire about any financial aid, scholarships, or installment payment options that may be available to help manage the cost of the course.

For detailed information checkout the following link:
[](https://iphi.edu.in/operation-theatre-technology)
Can I convert bulk MSG files to PST format?
Published: 2024-04-30 09:36:59

Hi, I have a collection of email messages in MSG format that I need to merge into a single PST file. Because I am facing problems searching for a reliable and user-friendly solution to import MSG to PST easily. And, I need a solution that supports email structure, attachments, and other metadata during the process. So, please anyone suggest an easy solution to do so?
Devox
Published: 2024-04-30 09:33:40

Devox Software is a global IT outsourcing enterprise with development centers located across five countries: Poland, Romania, Azerbaijan, Ukraine, and Georgia.

Flexibility stands at the core of our offerings. You have the freedom to select the engagement model that best fits your project needs, whether it’s outsourcing, outstaffing, assembling a dedicated team, or staff augmentation.

Our primary advantage is simplifying digital transformation for you. Simply communicate your needs, and we'll guide you through the optimal solutions, resources, and timelines for your enterprise. Our greatest asset is our people; we employ elite software developers who oversee your project from the initial estimation to the final release.

Thanks to our rigorous team selection process, Devox Software ensures a meticulously planned development cycle, skilled management, and effective communication.

Explore more at: [Devox Software](https://devoxsoftware.com/)
Top App Development Company Pune India
Tags: applicationdevelopment
Published: 2024-04-30 09:25:14


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zxasl9g92b7vd9kh2mui.jpg)


Empowering Visions: Custom Mobility Solutions for Startups & Businesses! Explore our infographic journey from concept to mobile reality. Dive deeper: Unlock Potential: https://mobisoftinfotech.com/mobisoft-company/app-development-company-in-pune #BusinessInnovation #PuneTech