My rule of thumb: if I need to do more then a trivial amount of DOM manipulation then I will use a framework, because otherwise I will end up writing my own anyway (which I can easily do) which wastes development time.
For projects with several developers a framework can help maintain common coding style and reduce ramp up time for new hires.
Also, good frameworks come with nice tooling that make for more productive development. For example, Vue + Vuex and the Vue browser plugin are great for inspecting the state and observing state transitions.
An example of my use case: I have a non-SPA app that receives various data via Websocket and the view is immediately updated. Several components take this same data and render it in different ways. Vue is excellent for this. I still use templating on the server side for the basic page structure.
Would be interested to see how you would implement that.
Vuex code as per docs to create state.stuff and mutations.update_suff() then in main Vue instance
mounted () {
this.$socket.subscribe(‘stuff’, data => {
this.$store.commit(‘update_stuff’, data);
});
where $socket is a subscriber client I wrote wrapped as a Vue plugin.Then inside the components
computed () {
stuff () {
return this.$store.state.stuff;
}
}
then use stuff as in your example.So very simple, and nothing that I couldn’t do without Vue but it takes care of the boring DOM manipulations and using the browser extension during development I can watch state change (which becomes interesting when there are multiple subscriptions with data combined).
<script src="/path/to/vuex.js"></script>
And then?What are mounted() and computed()? They look like methods of a class?
If the data is ready to render while still on the sever, I do so.
Thank you for clearly talking about why you'd use Vue and when you wouldn't. It's this sort of experience-based knowledge that I often lack.
I'm currently writing basic (very basic!) node stuff intended to further my understanding of Kubernetes: accessing a database, talking to a redis instance, etc etc. It can be bewildering trying to navigate the "oh-so-easy" basic examples of different frameworks and compare their different features.
Hm, that sounds like I'm asking for help, which I'm not - I just want to give an example of why your comments were so helpful to me!
I guess what other sites save on re-rendering html, they lose multiple times on bloated code.
https://news.ycombinator.com/item?id=18476247
While 30s is off the chart, I see bloat that needs multiple seconds everywhere. The new Reddit, AirBnB, the various Google tools etc etc.
However the majority of sites these days use some form of SPAs.
Also under a second is a very low bar to strive to. a fast round trip to the server is 100ms. A reasonable one is somewhere around 300ms. Displaying effects to changes is often under a millisecond in SPAs and is basically impossible to reach in Multi page applications.
I disagree, based on my experience of writing a reasonably complex non-SPA application which very much benefits from Vue.
I also think the fact that Vue Router ships as a separate app further suggests SPA is just one use case.
Do you have a reference for that claim? I very much doubt you are correct, but I'd be interested in seeing some stats either way, if they exist.
I'm not saying that React/Vue aren't important and drastically changing what's thought of as best-practices in web development... but just because everyone on HN uses a front-end framework for their websites doesn't mean "all websites" do it.
This lets you split your interface into more isolated components, and makes you free to use different framework depending on the type of interaction your page needs, as well as be able to update your site progressively.
React/Redux hasn't been around long enough for its best practices to solidify in the general industry so you'll often find that companies that picked up React have a hodge-podge of incorrectly used technologies included because they didn't know the use case for Thunks vs Sagas, how to use Reselect correctly, whether to store any given state in Redux or a Container, and so on.
Also, in those cases a few extra seconds for the initial load or the general size of the application don't matter. It's all better than your average Swing application ("Challenge accepted", said the Electron developer).
Although this isn't something contemporary frameworks seem to aim for (ExtJS is dying, and that's good), you get close enough to desktop UI development with Vue/Vuex/Ant Design, Angular/AngularMaterial or React/Material-UI/Redux-boilerplate-reducer-of-the-week.
The point of using Vue is data-binding with reactive models and components.
For your use case I agree Vue is overkill. A templating engine should be enough.
So you do...
...to make Vue render the list of objects.This is the only thing I ever use these frameworks for. Everything else I think I can implement in a better, leaner way myself. So I wonder if I should switch to a template engine instead.
What is the next most basic/common usecase for Vue?