-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Reorganize sidebar and some content; cannibalize reactivity page #1086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/v2/guide/instance.md
Outdated
@@ -16,46 +16,68 @@ var vm = new Vue({ | |||
|
|||
Although not strictly associated with the [MVVM pattern](https://en.wikipedia.org/wiki/Model_View_ViewModel), Vue's design was partly inspired by it. As a convention, we often use the variable `vm` (short for ViewModel) to refer to our Vue instance. | |||
|
|||
When you instantiate a Vue instance, you need to pass in an **options object** which can contain options for data, template, element to mount on, methods, lifecycle callbacks, and more. The full list of options can be found in the [API reference](../api/#Options-Data). | |||
When you create a Vue instance, you pass in an **options object**. The majority of this guide describes how you can use these options to create your desired behavior. For reference, you can also browse the full list of options can in the [API reference](../api/#Options-Data). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full list of options in
, not can in
.
src/v2/guide/instance.md
Outdated
``` | ||
|
||
Although it is possible to create extended instances imperatively, most of the time it is recommended to compose them declaratively in templates as custom elements. We will talk about [the component system](components.html) in detail later. For now, you just need to know that all Vue components are essentially extended Vue instances. | ||
We'll talk about [the component system](components.html) in detail later. For now, just know know that all Vue components are also Vue instances, and so accept the same options object (except for a few root-specific options). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate know
.
vm.a // => 3 | ||
``` | ||
|
||
When this data changes, the view will re-render. It should be noted that properties in `data` are only **reactive** if they existed when the instance was created. That means if you add a new property, like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't "data" plural?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, yes, but in practical use I think most people treat it as singular, e.g. "My data is backed up."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phanan I'm still open to changing it though. What do you think?
src/v2/guide/instance.md
Outdated
visitCount: 0, | ||
hideCompletedTodos: false, | ||
todos: [], | ||
errorMessage: null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest error
instead of errorMessage
, as a "message" would imply a string type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, though in this case, I'd still actually still have errorMessage
be null
when it'll be a string later. The reason is a blank error message can still mean something different than a non-existent one.
Each Vue instance goes through a series of initialization steps when it is created - for example, it needs to set up data observation, compile the template, mount the instance to the DOM, and update the DOM when data changes. Along the way, it will also invoke some **lifecycle hooks**, which give us the opportunity to execute custom logic. For example, the [`created`](../api/#created) hook is called after the instance is created: | ||
Each Vue instance goes through a series of initialization steps when it's created - for example, it needs to set up data observation, compile the template, mount the instance to the DOM, and update the DOM when data changes. Along the way, it also runs functions called **lifecycle hooks**, giving users the opportunity to add their own code at specific stages. | ||
|
||
For example, the [`created`](../api/#created) hook can be used to run code after an instance is created: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean can be use to run after
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, can be used to run code after
does actually say what I mean. What meaning does it have for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I misread it then. Yeah, it makes perfect sense to me now.
src/v2/guide/reactivity.md.hidden
Outdated
!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! NOTE FOR TRANSLATORS !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! Don't both translating changes to this page yet, !! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't bother?
@phanan Thanks for your excellent review. 😻 Great attention to detail! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, Chris.
- I think the new sidebar categories are a nice improvement. Easy to navigate and contain the expected content. 🙂 Maybe the
Transitions & Animation
can go aboveReusability & Composition
but I am not sure since the latter contains some more advanced features likeJSX
andPlugins
. Also, I wonder whySingle File Components
page is under tooling. Wouldn't it fit better in theComponents
category? - Yes!
- I like it, a small screenshot of DevTools in action would also look nice.
- It's just fine.
- Still good, didn't even notice the reorganization.
☺️ How about adding a warning on thekey
section to note that it's required when iterating components? I'd also like to have a warning in the arraycaveats
section, just to draw attention.
src/v2/guide/filters.md
Outdated
<div v-bind:id="rawId | formatId"></div> | ||
``` | ||
|
||
<p class="tip">Vue 2.x filters can only be used inside mustache interpolations and `v-bind` expressions (the latter supported in 2.1.0+), because filters are primarily designed for text transformation purposes. For more complex data transforms in other directives, you should use [Computed properties](computed.html) instead.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paragraph repeats the way of using filters.
The part "(the latter supported in 2.1.0+)" can be moved to the intro paragraph, so this can be: "Filters are primarily designed for text transformation purposes. For more complex data transforms....."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! I just removed the redundancy. 🙂
|- EditTodoButton | ||
|- TodoListFooter | ||
|- ClearTodosButton | ||
|- TodoListStatistics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if it's a good idea to show an example component tree at this point. My concern is that even though it's just an example, people with little experience may get confused or try to follow it as a rule.
If you are going to keep it, maybe it's safer to make it more general. For example:
Root Instance
|- TodoList
|- TodoItem
|- CreateTodoItem
|- ShowTodoItem
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing this to my attention! I'll do a little more user testing on this part.
Thanks for the review @hootlex! 😄
I might be misunderstanding, but isn't it already above Reusability & Composition? If you're suggesting the opposite of what I'm thinking though, then I put Transition & Animation first because it allows you to do something new, whereas Reusability & Composition just allow you to build the same kinds of apps and components, just organized or optimized differently. Does that make sense?
Because they're not actually a feature of Vue core, but of vue-loader/vueify/etc. They're not possible without build tools.
I actually experimented with adding a screenshot there, but I worried that it took up too much vertical space. Once people have the devtools, I'd like it to be easy to skip over this section to the actual installing of Vue. Once people click through, they'll see a nice screenshot. 🙂
We do currently have it stand out in a version note and users also receive a warning in the console when using the dev build, so I feel like we might have this well-covered already.
This is something a lot of people have missed in the past, because it was below the section about components that we encouraged people to skip. 😅 My hope now is that with the reordering of this page, many more people will see it. It is important though, so if we still notice a problem with new users, this is a measure I'll consider. I'm just not sure which part we'd turn into a warning, as the entire section is really a sort of warning - and hopefully, the fact that "Caveats" exists in the title will draw attention to it. |
@chrisvfritz it seems that you have thought everything 😄 Regarding the "Animations & Transitions", I wanted to say the opposite. Hadn't thought of it this way. It makes sense to show more features before diving into specific needs. 👍🏻 About "Array Caveats", hopefully, people will notice it with the new order. Otherwise, it's hard to decide in which part to emphasize. It's like the whole section should be a warning. |
We got a couple reviews, so I'm going ahead and merging this. I at least feel confident there's nothing disasterous here. 😄 |
Just weighing in, spreading info about reactivity throughout the guide as it's relevant seems pretty helpful, but I've found the 'Reactivity In Depth' page an extremely useful reference, especially when working with vuex mutations & dealing with some harder-to-diagnose bugs resulting from setting fields incorrectly. It'd be nice if a consolidated summary of this behavior could stick around somewhere - I needed to reference it today and had to pull it up from archive. |
@cwill The page is also still here in source, partially rewritten. The plan is to expand it into a Contributor's Guide that's even more detailed than the current document. As for the use cases you're thinking of, if the information isn't easily searchable either here or in the Vuex docs, opening an issue would be very welcome. In the API doc in particular, we've been adding more of these kinds of warnings. |
Ah, adding the relevant warnings to the API docs mostly covers the cases I was concerned about -- I'll keep an eye out :) |
@cwill Thanks! 😄 |
Maybe a bit late, but I still think the Reactivity Page should be preserved somewhere, especially for those who wish to have a go-to place when they need to point co-workers to a "source" where explains the whole thing in one place. I'm thinking maybe we should one extra section titled "Advanced / Internals" that hosts the reactivity chapter and the render function chapter, as both of these somewhat relies on knowledge of how Vue actually works under the hood. IMO these are not only valuable for contributors but also for normal users. |
As a normal user, the reactivity docs have been invaluable in the past. Definitely agree that they should live in a separate section. |
@yyx990803 Sounds good! I'll have it back up in a new section soon. |
* Reorganize sidebar and some content; cannibalize reactivity page (vuejs#1086) * reorganize sidebar and some content; cannibalize reactivity page * Fix typo in instance.md * Fix typo in instance.md * Change errorMessage: null to error: null in instance.md * Fix typo in reactivity.md.hidden * remove redundant note about filters # Conflicts: # src/v2/api/index.md # src/v2/guide/deployment.md # src/v2/guide/events.md # src/v2/guide/forms.md # src/v2/guide/installation.md # src/v2/guide/instance.md # src/v2/guide/list.md # src/v2/guide/migration-vue-router.md # src/v2/guide/reactivity.md.hidden # src/v2/guide/render-function.md # src/v2/guide/syntax.md # src/v2/guide/transitioning-state.md # src/v2/guide/transitions.md # themes/vue/layout/partials/toc.ejs * Update date * Fix lint
Browse the PR live here.
What I did
mounted
andupdated
now covervm.$nextTick
.Vue.set
/vm.$set
) under List Rendering, where the caveats for arrays were already listed.v-for
features. 😬->
and=>
to represent expression return values, so I arbitrarily standardized on=>
.Questions