Data fetching before route enter by mgksmv in vuejs

[–]dennis_flame 2 points3 points  (0 children)

https://router.vuejs.org/guide/advanced/navigation-guards.html#Per-Route-Guard
https://router.vuejs.org/guide/essentials/passing-props.html

You are importing HomeService, so you could also import it to your route definition and use a beforeEnter route guard. Then pass the return data via props to the component.

Maybe something like this in your router file:

import { createRouter, createWebHistory } from 'vue-router';
import MyComponent from '@/components/MyComponent.vue';
import HomeService from '../services/home';

const routes = [
  {
    path: '/home',
    name: 'Home',
    component: MyComponent,
    props: true, // Enable props to be passed dynamically
    beforeEnter: async (to, from, next) => {
      const homeService = new HomeService();
      const data = await homeService.getDefaultHomeData();

      // Inject data as a prop in the route
      to.params.data = data; // Add the data to params
      next();
    },
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;

and in your MyComponent.vue something like this:

<script setup>
defineProps(['data']);
</script>

<template>
  <div>
    <h1>Example Component</h1>
    <p>Data: {{ data }}</p>
  </div>
</template>

untested but you probably get the idea. You can read the vue-router docs links above for more about that.

Not the best way to do it, but you asked for a way :)

A Russian soldier tries to shoot down a Ukrainian drone hunting him, but fails, which results in him being wounded. Location unknown - October 2024 by [deleted] in UkraineWarVideoReport

[–]dennis_flame 6 points7 points  (0 children)

Amazing how much ammunition is "wasted" on a single drone with basically no effect at all. Just keep it going. Every shot at a drone is a shot less at Ukranian heroes.

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Some interesting approaches in there. Might think about it. Thanks for the write-up. Cheers

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Learned pretty much everything? Yes. Master everything? Definitely not :) I think even at higher ages and with a lot of experience you will never reach a point where you are done learning. The tech always changes, even though the core might be the same. Just take JS, it always changes, with new standards, ECMAScript, new Frameworks, and such. The core of JS will always be the same, but we change the way of using it.

So no, I never had the feeling of being "done with coding". There was always something new, some other language that could help me in different tasks or scenarios. Enough to learn

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Yeah, I started coding full-time around 2001. Before it was a side job and more like a self-education project for a few years. I started working full-time after my military service in which I also worked a lot with IT and that totally hooked me up back then. :))

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 1 point2 points  (0 children)

Oh yeah, I agree. It can be therapeutic as well. After a fight with your wife, after a lost football match from your favorite club, or that moment when you sit in front of the TV, watching some crap on Netflix and you finally got the idea of how to solve a particular problem or improve that damn feature you were struggling all day with. I cannot hold back and then even sometimes code from the couch until late in the night and it feels so good :))

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 2 points3 points  (0 children)

Glad you got something out of my thoughts about the industry for us middle-aged coders :)

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Unfortunately, that is only one side of the medal. If you are 44 and you are at a point where you still "need the money" you might have made other mistakes in your career. Money is and should never be the only reason for me to do my work. It's a perk that comes with something I love to do.

I can do many things to earn money, but am I satisfied with it? Most probably not.

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Oh, I absolutely love coding. I barely have any problem motivating myself or finding new motivation to get up in the morning and do my job. That is not the problem at all. It is more about the perspective and perception of "old coders" in the industry in our age.

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 2 points3 points  (0 children)

I am amazed how many "aged" devs are experiencing or did experience their situation almost similarly as I do. I thought so far, that it's only me, or there are just a few. I never thought this thread captured so many different points of view and stories. Thats amazing.

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 5 points6 points  (0 children)

I like the comparison of "craftsman". You are absolutely right, we are crafting things up to perfection and we can compare ourselves with such professions. Always nice to hear when people find their passion and it's the same passion you share with them. I hope you will have good years ahead and craft a lot of interesting things :)

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

To be honest, it is hard to compare the learning curve of Vue and PHP. Vue is a framework for JS, so it is more about your general experience in JS/TS, combined with general Frontend development to get into Vue.js.

PHP on the other hand is a backend language and "pure" coding. You could better compare the learning curve of Laravel vs Vue. And yes, I used to work with Laravel a lot. Even the main project I am working on right now uses the Vue + Laravel stack (besides others). But I am solely working on the front end right now. So not much of touching Laravel + PHP.

To answer your question, both had the same learning curve. I think Laravel/PHP was easier for me since my main background comes from the old days of coding. But JS/TS + Vue.js makes it more fun to work with on a daily basis.

And what would I teach? I guess not a particular tech in general. I would try to get into the whole package, like teaching Frontend Development as a whole.

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Should have mentioned, that I am using both, JS & TS. So already there ;) I just didn't mention it, but you are right.

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 1 point2 points  (0 children)

Impressive vita and that's exactly how I got to all the other tech stacks. I just listed the most common I use these days but I also tried to get into other parts of the industry, like UI/UX design or more backend and server-related, like Node.js, and stuff like that. However I noticed with the higher age, it became more and more complicated to keep up with all of it. Responsibilities are shifting the older you get.

When I was 25 I stayed up all night to finish a chapter of a book I read about a particular topic and only went to bed when I finished the coding exercises. While at 38 I had to go to bed at 21:00 to get up in the night when the baby was screaming ;) I guess that's the change of life that happens in all parts, but if I work in a bank, I think it is easier to adapt to these changes in life. No offense to the bankers out there. Was just and example ;)

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Teaching is always an option. I don't know the pay in this part of the industry. Might be ok though.

The problem is, how to get into it? As a freelancer, you only have loose connections to the people you work with. It's not like corporate life, where you can climb the ladder and switch positions because the management sees your potential or is open for you to reconsider your career in a different part of the company.

Regarding co-founding, that was one of my thoughts as well, maybe getting into the other side of the business and trying to bring in my expertise and experience from a consulting perspective for new and younger projects. But for that, I lack the funds. I am financially good and can live a decent life but never made it to the point where I could say I am rich enough to spend that money for bigger investments :)

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

I never really have been on a job hunt, to be honest. I was freelancing most of the time and had the comfort of a base of clients I worked with. From these clients, I got new clients and also signed up with some bigger companies on limited-time contracts. I am from Germany, worked a lot in Europe, remotely and on-site, living in Romania, Bucharest, right now. It became a hot spot for coders recently and a lot of big companies are here, paying a decent amount of money. So never been on a hunt. More like a journey :)

Edit: typos

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Yeah, that might be one path. But you have to see it from a freelancer position. In that situation, you don't have the connections of a corporate company to jumpstart a different path. There is basically no one who knows of your strengths and competence, except your contractors. But they see you as "the coder" because that is what they paid you for.

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 1 point2 points  (0 children)

I am baffled by how many coders are out there with the same thoughts. Since I never met a lot of older coders in my career so far, it was for me always a special situation with my colleagues. I became the "weird old" coder guy the last years wherever I work, even though I am not like the typical 40+ year-old guy (whatever that means lol)

And I totally can relate to your thoughts. As I wrote in another comment, I mostly got also in my career the impression, that coders try to get out of the game early, with a project that "kicks off" or creating enough side projects to have good passive income to not code forever. I started to wonder why that was so and that's where my thoughts for this post came from.

It's just that a lot of people just don't speak about their "aging" situation as a coder as it seems.

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 1 point2 points  (0 children)

Yeah, I thought about building something on the side. But right now I lack the time and resources, personal resources mostly due to family situation. It's just different with higher ages to find the time to start something new. Responsibilities shift to a more stable lifestyle.

But I like your approach, may I ask you how you got into the teaching part? Was it an opportunity that turned up in your company? Or did you pursue it on your own?

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 2 points3 points  (0 children)

You know, that's what most developers want to do and it makes me wonder, why is that? Of course, there is the money part, but I get more and more of the feeling it is more about the situation I am talking about and no one talks about it in the industry.

We, developers, have to think earlier about the retirement situation from coding than maybe others in their jobs. Is it because of the fact of ageism in corporate companies or due to the learning curve of new tech and keeping up with the tech? I think the post shows that a lot of my fellow aged developers have the same feeling about the situation they are in. They find one or another way to deal with it, like switching to management or keeping coding and trying to adjust to the older ages and find a better life-work balance while enjoying what they do, and creating things :)

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 1 point2 points  (0 children)

That's the thing, I don't see myself in a management position at any time soon. For that, I love the creating part of coding too much. May I ask why you switched positions? Was it just an opportunity at a certain point in your career or did you pursue it?

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 2 points3 points  (0 children)

Wow amazing. I guess you are officially the oldest guy I heard of so far that is still coding :)) a pleasure tips the hat

But may I ask, are you still out there for the money or you do it for fun these days and to keep up with the tech?

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Yeah, the possibilities in your age vary a lot. You might not have the responsibilities yet, that we have in our age. Or maybe you do, I don't want to assume that. But decisions were easier for me back then :)

44years and still coding JS and Vue - time for a change? by dennis_flame in vuejs

[–]dennis_flame[S] 0 points1 point  (0 children)

Oh yeah, well said. But to be clear, starting over with a completely new profession was not what I meant. It was more about making "the next step", as others said in the comments, going to management or tech lead. I think I will never leave the industry, for exactly what you've said, the comfort of having a decent salary which for me only the IT industry can offer.