Skip to content

Commit 3f7b443

Browse files
Generally improve the README
1 parent eeb35c0 commit 3f7b443

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

README.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ new Vue({
4444
computed: {
4545
username: {
4646
// Using vue-resource
47-
return Vue.http.get('/get-username-by-id', { id: this.userId })
47+
return Vue.http.get('/get-username-by-id/' + this.userId)
4848
// This assumes that this endpoint will send us a response
4949
// that contains something like this:
5050
// {
@@ -65,7 +65,7 @@ new Vue({
6565
},
6666
asyncComputed: {
6767
username: {
68-
return Vue.http.get('/get-username-by-id', { id: this.userId })
68+
return Vue.http.get('/get-username-by-id/' + this.userId)
6969
.then(response => response.data.username)
7070
}
7171
}
@@ -100,18 +100,19 @@ import AsyncComputed from 'vue-async-computed'
100100
/* Initialize the plugin */
101101
Vue.use(AsyncComputed)
102102
103-
/* Then, when you create a Vue instance (or component),
103+
/*
104+
Then, when you create a Vue instance (or component),
104105
you can pass an object named "asyncComputed" as well as
105-
or instead of one named "computed". The functions you pass
106-
to "asyncComputed" should return promises, and the values
107-
those promises resolve to are then asynchronously bound to
108-
the Vue instance as the promises resolve. Just like with
109-
normal computed properties, if the data the property depends
110-
on changes then the property is re-run automatically.
106+
or instead of the standard "computed" option. The functions
107+
you pass to "asyncComputed" should return promises, and the values
108+
those promises resolve to are then asynchronously bound to the
109+
Vue instance as they resolve. Just as with normal computed
110+
properties, if the data the property depends on changes
111+
then the property is re-run automatically.
111112
112113
You can almost completely ignore the fact that behind the
113114
scenes they are asynchronous. The one thing to remember is
114-
that until a asynchronously property's promise resolves
115+
that until a asynchronous property's promise resolves
115116
for the first time, the value of the computed property is null.
116117
*/
117118

@@ -130,10 +131,11 @@ const vm = new Vue({
130131
}
131132
})
132133

133-
/* Until one second has passed, vm.sum will be null.
134-
After that, vm.sum will be 5. If you change vm.x or vm.y,
135-
one second later vm.sum will automatically update itself to be
136-
the sum of what you set vm.x and vm.y to be a second before.
134+
/*
135+
Until one second has passed, vm.sum will be null. After that,
136+
vm.sum will be 5. If you change vm.x or vm.y, then one
137+
second later vm.sum will automatically update itself to be
138+
the sum of the values to which you set vm.x and vm.y the previous second.
137139
*/
138140
````
139141

@@ -146,11 +148,13 @@ If you want to use a custom logging function, the plugin takes an `errorHandler`
146148
For example:
147149

148150
````js
149-
Vue.use(AsyncComputed, { errorHandler: function (msg) {
150-
console.log('Hey, an error!')
151-
console.log('---')
152-
console.log(msg)
153-
})
151+
Vue.use(AsyncComputed, {
152+
errorHandler (msg) {
153+
console.log('Hey, an error!')
154+
console.log('---')
155+
console.log(msg)
156+
}
157+
)
154158
````
155159

156160
You can pass `false` in order to silently ignore rejected promises.

0 commit comments

Comments
 (0)