![]() ![]() In my head even though it's a hack it's still applied only on a couple of layouts (as opposed to every route component) and therefore is much better localized than watch (which is also a hack to be frank). I guess the justification for my case is that I only have 3 level nesting, and re-mounting matters only on the last level. To get started, you'll need this package. It's entirely optional, but in many cases, you'll want to leverage the package. Introducing Vue Routing Routing in Vue is handled by a separate package from the core Vue package. The mere fact that Vue Router doesn't have an option to key the RouterView by the props it injects makes me really sad (and occasionally want to build a plugin or similar) - because keying them manually is also tedious and somewhat error prone if you have complex route hierarchy. Figure 1: Anatomy of routing With that in mind, let's see how Vue implements routing. In this case it also comes at the expense of DX (because as mentioned above, I don't really like thinking in watch terms). Unless you're doing something really DOM-heavy, you (and, more importantly, your users) won't notice a performance impact of remounting anyway. I don't really care that much about DOM reusing on router changes. (In fact I've just checked, I've built very big and very dynamic applications and managed to not use watch not even once, and this is something I recommend to not do to the teammates as well.) instead of thinking "here's my data, I expect it (and all its deps) to be rendered" you start thinking "when data changes, do something" which is, in my opinion, a slippery path to causality issues and ultimately a lot of □ and debugging. I tend to stay away from watch, and not because of performance problems (it's as performant as other Vue's reactive stuff like computed props and template expressions), but because it breaks the declarativeness of the view layer of the application. So, what I'm about to say is probably very controversial in Vue community (and kind of off topic), so sorry in advance. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |