Skip to content

Commit 145a821

Browse files
johannes-zfoxbenjaminfox
authored andcommitted
Updated README to reflect new errorHandler arguments (#73)
* added vm and info to errorHandler. * updated README for `errorHandler` (#71).
1 parent fdadbac commit 145a821

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ new Vue({
4949
return Vue.http.get('/get-username-by-id/' + this.userId)
5050
// This assumes that this endpoint will send us a response
5151
// that contains something like this:
52-
// {
52+
// {
5353
// "username": "username-goes-here"
5454
// }
5555
.then(response => response.data.username)
@@ -98,7 +98,7 @@ Alternately, you can link it directly from a CDN:
9898
9999
```html
100100
<script src="https://unpkg.com/vue-async-computed"></script>
101-
<!--
101+
<!--
102102
That will always point to the latest version of vue-async-computed.
103103
You probably want to instead pin it to a specific version:
104104
-->
@@ -133,7 +133,7 @@ Vue.use(AsyncComputed)
133133
Vue instance as they resolve. Just as with normal computed
134134
properties, if the data the property depends on changes
135135
then the property is re-run automatically.
136-
136+
137137
You can almost completely ignore the fact that behind the
138138
scenes they are asynchronous. The one thing to remember is
139139
that until a asynchronous property's promise resolves
@@ -185,7 +185,7 @@ new Vue({
185185
return Vue.http.get('/post/' + this.postId)
186186
.then(response => response.data.postContent)
187187
},
188-
// The computed proporty `blogPostContent` will have
188+
// The computed proporty `blogPostContent` will have
189189
// the value 'Loading...' until the first time the promise
190190
// returned from the `get` function resolves.
191191
default: 'Loading...'
@@ -392,10 +392,14 @@ new Vue({
392392
393393
By default, in case of a rejected promise in an async computed property, vue-async-computed will take care of logging the error for you.
394394
395-
If you want to use a custom logging function, the plugin takes an `errorHandler` option, which should be the function you want called with the error information. By default, it will be called with the error's stack trace as an argument, but if you want the raw error itself you can set the
396-
`useRawError` option to `true`.
395+
If you want to use a custom logging function, the plugin takes an `errorHandler`
396+
option, which should be the function you want called with the error information.
397+
By default, it will be called with only the error's stack trace as an argument,
398+
but if you register the `errorHandler` with `useRawError` set to `true` the
399+
function will receive the raw error, a reference to the `Vue` instance that
400+
threw the error and the error's stack trace.
397401
398-
For example:
402+
For example:
399403
400404
```js
401405
Vue.use(AsyncComputed, {
@@ -409,11 +413,11 @@ Vue.use(AsyncComputed, {
409413
// Or with `useRawError`:
410414
Vue.use(AsyncComputed, {
411415
useRawError: true,
412-
errorHandler (err) {
416+
errorHandler (err, vm, stack) {
413417
console.log('An error occurred!')
414418
console.log('The error message was: ' + err.msg)
415419
console.log('And the stack trace was:')
416-
console.log(err.stack)
420+
console.log(stack)
417421
}
418422
)
419423
```

0 commit comments

Comments
 (0)