-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Reduce instances of words that shouldn't be used in educational writing. #1126
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
Changes from all commits
2d1da92
e2a8aca
bb34256
a4ba1f2
2370313
f38cb71
423616f
c5336b2
033ea04
f051502
bc7bd37
2dad485
6e4d24b
04ad983
77a3174
9e3cb49
381da73
547cd49
c327986
081a003
f74a67b
8964f2a
858024f
976308e
f0e99c7
f8f0fdd
de21684
0547bd4
0aa0c61
8a84294
95d9e85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,19 +22,19 @@ new Vue({ | |
}) | ||
``` | ||
|
||
Then `"My App"` will be logged to the console. It's that simple! | ||
Then `"My App"` will be logged to the console! | ||
|
||
## The Importance of Scoping Instance Properties | ||
|
||
You may be wondering: | ||
|
||
> "Why does `appName` start with `$`? Is that important? What does it do? | ||
|
||
No magic is happening here. `$` is simply a convention Vue uses for properties that are available to all instances. This avoids conflicts with any defined data, computed properties, or methods. | ||
No magic is happening here. `$` is a convention Vue uses for properties that are available to all instances. This avoids conflicts with any defined data, computed properties, or methods. | ||
|
||
> "Conflicts? What do you mean?" | ||
|
||
Another great question! If you just set: | ||
Another great question! If you set: | ||
|
||
``` js | ||
Vue.prototype.appName = 'My App' | ||
|
@@ -46,7 +46,7 @@ Then what would you expect to be logged below? | |
new Vue({ | ||
data: { | ||
// Uh oh - appName is *also* the name of the | ||
// instance property we just defined! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "just" implies proximity, rather than conceptual simplicity There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does. I think the "recently" is implied, but happy to revert. I definitely made some judgement calls, so comments welcome. |
||
// instance property we defined! | ||
appName: 'The name of some other app' | ||
}, | ||
beforeCreate: function () { | ||
|
@@ -143,7 +143,7 @@ As long as you're vigilant in scoping prototype properties, using this pattern i | |
|
||
However, it can sometimes cause confusion with other developers. They might see `this.$http`, for example, and think, "Oh, I didn't know about this Vue feature!" Then they move to a different project and are confused when `this.$http` is undefined. Or, maybe they want to Google how to do something, but can't find results because they don't realize they're actually using Axios under an alias. | ||
|
||
__The convenience comes at the cost of explicitness.__ When just looking at a component, it's impossible to tell where `$http` came from. Vue itself? A plugin? A coworker? | ||
__The convenience comes at the cost of explicitness.__ When looking at a component, it's impossible to tell where `$http` came from. Vue itself? A plugin? A coworker? | ||
|
||
So what are the alternatives? | ||
|
||
|
@@ -171,7 +171,7 @@ var App = Object.freeze({ | |
|
||
<p class="tip">If you raised an eyebrow at `Object.freeze`, what it does is prevent the object from being changed in the future. This essentially makes all its properties constants, protecting you from future state bugs.</p> | ||
|
||
Now the source of these shared properties is much more obvious: there's an `App` object defined somewhere in the app. To find it, developers need only run a project-wide search. | ||
Now the source of these shared properties is more obvious: there's an `App` object defined somewhere in the app. To find it, developers can run a project-wide search. | ||
|
||
Another advantage is that `App` can now be used _anywhere_ in your code, whether it's Vue-related or not. That includes attaching values directly to instance options, rather than having to enter a function to access properties on `this`: | ||
|
||
|
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.
"simple" emphasizes the lack of complexity of the expression, rather than conceptual simplicity
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.
IMO it's superfluous, and reads more simply (ha!) without it.