Live data from Hacker News

Vue.js 3

github.com

161–170 of 308 posts

Re: Vue.js 3

#161
post #151

Earlier quoted context omitted.

I'm not sure about React's capability with this, but Vue can very easily run with no build stage. You can load Vue from a CDN and use a couple lines of JS to point it at a DOM element in your app. Then you can write a plain JS Vue object (what goes inside the tags in a .vue file), and all this logic will apply inside the element you pointed it at. You can also write components, although that gets a little clunky with…

I find it amusing that you are allowed to run arbitrary Javascript but can't run NodeJS on your machine. Sometimes corporate security can be a theatre.

Frontend JavaScript is sandboxed and you can't really disable it without crippling 90% of websites.

node.js code can cripple your system way more. So this does not really seem surprising.

Re: Vue.js 3

#162

Earlier quoted context omitted.

I'm not sure about React's capability with this, but Vue can very easily run with no build stage. You can load Vue from a CDN and use a couple lines of JS to point it at a DOM element in your app. Then you can write a plain JS Vue object (what goes inside the tags in a .vue file), and all this logic will apply inside the element you pointed it at. You can also write components, although that gets a little clunky with…

React can, but less ergonomically than most developers are used to.

Could you comment more on how it's done?

Re: Vue.js 3

#163

Why is IE11 support still important now? I can't find exact stats on it, but it seems <2%. Surely projects which still want to support IE11 could still stick for a while with Vue2.

IE11 is still heavily used in some industries, such as healthcare. Browser statistics services usually don't pick up on a lot of IE11 use because it's on internal networks.

I wish I could ignore IE11, but the reality is that I can't.

Re: Vue.js 3

#164
post #90
post #80

Earlier quoted context omitted.

Sure, you can use HBS (or even vanilla) to render a piece of dynamic HTML. That's not really the problem these libraries are solving. You could also create your own components with HBS templates and figure out how compose them to render a tree of components. That's not too hard to figure out either. The problem is really in updating the DOM when state changes somewhere in your application. In the jQuery days we had t…

You say updating the DOM becomes messy but give no arguments why that would be the case. Say a function changes the cars array. All it has to do to update the DOM is: document.querySelector('#cars').innerHTML=carsTemplate(cars); Where carsTemplate is a HandleBars template that on page load has been initialized with the html to render the list of cars.

Now let's say your data (cars) changes. Due to some interaction, a car gets added to the list.

What the above code will do is completely replace the HTML for the entire list of cars, when really all that needs to happen is appending one to the end. If the list is big, your app is now slow.

If the user has something focused or edited in that list of cars (let's say they're editing the description of one), not only is focus lost on that field now (its DOM node was completely wiped out and replaced), but the user's text they were editing is also lost.

Re: Vue.js 3

#165
post #115

Earlier quoted context omitted.

This is a popular opinion particularly if all someone pays attention to is Twitter and Reddit but I'd argue it is a wrong opinion. Angular is alive and well, and being used/adopted every day for projects no one hears about. It isn't the "sexy" choice, but it is the one a lot of companies make. And if you're gonna point to opinion polls, and all kinds of respect to those who put them out, but they have a hard time cap…

Depends where you live and work I suppose. I used to work in a consultancy firm in Norway that was all in on Angular two-three years ago. Angular has been very popular in enterprise here. But Twitter and Reddit reach enterprise too in the end. The consultancy firm has now switched more or less entirely over to React because Angular is so out of vogue.

I used to work for a big financial analytics company that used Angular 1.5 for everything. Around the time I left, they started migrating to VueJS instead. Obviously this is all anecdotal, and I have no doubt AngularJS is still being used in a lot of places, but I think there's reason to believe its share might be shrinking.

Re: Vue.js 3

#166

Why is IE11 support still important now? I can't find exact stats on it, but it seems <2%. Surely projects which still want to support IE11 could still stick for a while with Vue2.

IE11 is still heavily used in some industries, such as healthcare. Browser statistics services usually don't pick up on a lot of IE11 use because it's on internal networks. I wish I could ignore IE11, but the reality is that I can't.

Thanks for sharing

Re: Vue.js 3

#167
post #149

Earlier quoted context omitted.

Why can't React do the same?

Please someone correct me if I'm wrong. It seems like you can only implement React using the full "modern JS stack", i.e. Node/Webpack/... So if you want to use it on one page, it's a hard sell to set up all that infrastructure (and document it for the team) On some sites I've used Vue.js by simply adding a tag with vue.min.js. On sites already using Gulp or similar, it's pretty simple to incorporate the Vue bundle a…

React can be added to a page with just a script tag in the same way as Vue:

https://reactjs.org/docs/add-react-to-a-website.html

Having said that, React is normally used with JSX syntax, which requires a compile step.

You _can_ use it with "raw" `React.createElement()` calls, but that's generally unwieldy and almost no one does that.

However, there's a very neat library called https://github.com/developit/htm , which is an almost-JSX-compatible syntax that uses JS template literal strings, and requires no compile step.

Re: Vue.js 3

#168

I don't really understand the composition API. Doesn't passing values by reference which can be modified anywhere downward the tree make your app difficult to reason and debug it?

I had a similar misunderstanding when I first saw it, but globally declaring reactive variables and passing them around isn't really what it's about. Take, for example: https://github.com/antfu/vueuse/blob/master/packages/core/us.... Any component that wants to use a reactive reference to mouse coordinates can `const { x, y } = useMouse()` in `setup`, but `x` and `y` will refer to different objects in each of those components (since the `ref()` is instantiated inside the call to `useMouse()`). The functionality is what's shared between components, not the state/references.

That said, if you want to use the composition api to share state you can, and you can pretty easily set up some structure to restrict mutability:

    // useStore.ts
    import { reactive, readonly } from 'vue'

    export const useStore = () => {
      const state = reactive({ count: 0 })
      const increment = (val = 1) => state.count += val

      return {
        state: readonly(state), // Readonly so state can't be mutated directly...
        increment, // ...only through the mutations provided, like Vuex
      }
    }

    // store.ts
    import { useStore } from './useStore'
    export const store = useStore() // Now components can share this instance

    // MyCounter.vue
    import { store } from './store'

    export default {
      setup: () => ({
        count: store.state.count,
        onClick: () => store.increment(5),
      }),
    }
Or you can just keep using Vuex for sharing state and use the composition API for sharing self-contained bits of functionality. Or, if nothing else, using the `setup` method instead of the Options API just gives you much more control over how you organize your own code within a component.

Re: Vue.js 3

#169
post #149

Earlier quoted context omitted.

Why can't React do the same?

Please someone correct me if I'm wrong. It seems like you can only implement React using the full "modern JS stack", i.e. Node/Webpack/... So if you want to use it on one page, it's a hard sell to set up all that infrastructure (and document it for the team) On some sites I've used Vue.js by simply adding a tag with vue.min.js. On sites already using Gulp or similar, it's pretty simple to incorporate the Vue bundle a…

This looks like the perfect place to mention my project template used to create Vue 3 apps without the need for Webpack or any other build tool:

https://github.com/arijs/vue-next-example

I already integrated vue-router, and am currently on the process of fully integrating Vue server renderer. I already have a basic usage implemented, where the home page is compiled to a html string, but I still need to make it easy to compile all pages and to implement client-side component hydration.

Re: Vue.js 3

#170
post #63

I am impressed with the amount of energy Evan is pouring in this open source project. I am curious if he ever experience boredom working on Vue. I am also curious if Patreon based income is sustainable for the long run. What if there's another new sexy JS framework in the future?

> What if there's another new sexy JS framework in the future?

I am sure he can save a lot, with that income.

I am sure he could find a normal job, with those skills.

I am sure he could be a freelancer, with "created vue.js" as reference.

His Patreon based income would slowly die with the decline of Vue.js and he'd have enough time to look for something else.

Post reply on HN