Skip to content

Commit 79777ee

Browse files
committed
tweak readme and example
1 parent bb0edcb commit 79777ee

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,14 @@ Convert vue.$on (including lifecycle events) to Observables. The emitted value i
195195
var vm = new Vue({
196196
created () {
197197
this.$eventToObservable('customEvent')
198-
.subscribe((event) => console.log(event.name,event.msg))
198+
.subscribe((event) => console.log(event.name,event.msg))
199199
}
200200
})
201201

202202
// vm.$once vue-rx version
203203
this.$eventToObservable('customEvent')
204204
.take(1)
205-
205+
206206
// Another way to auto unsub:
207207
let beforeDestroy$ = this.$eventToObservable('hook:beforeDestroy').take(1)
208208
Rx.Observable.interval(500)
@@ -247,7 +247,7 @@ var vm = new Vue({
247247
248248
Convert function calls to observable sequence which emits the call arguments.
249249

250-
This is a prototype method added to instances. Use it to create a shared hot observable from a function name. The function will assigned as a vm method.
250+
This is a prototype method added to instances. Use it to create a shared hot observable from a function name. The function will be assigned as a vm method.
251251

252252
```html
253253
<custom-form :onSubmit="submitHandler"></custom-form>
@@ -262,14 +262,24 @@ var vm = new Vue({
262262
}
263263
})
264264
```
265-
Or, use the `observableMethods` convenience option:
265+
266+
You can use the `observableMethods` option to make it more declarative:
267+
266268
``` js
267269
new Vue({
268-
observableMethods: { submitHandler:'submitHandler$' }
270+
observableMethods: {
271+
submitHandler:'submitHandler$'
272+
// or with Array shothand: ['submitHandler']
273+
}
269274
})
270275
```
271-
[example](https://github.com/vuejs/vue-rx/blob/master/example/counter-function.html)
272276

277+
The above will automatically create two things on the instance:
278+
279+
1. A `submitHandler` method which can be bound to in template with `v-on`;
280+
2. A `submitHandler$` observable which will be the stream emitting calls to `submitHandler`.
281+
282+
[example](https://github.com/vuejs/vue-rx/blob/master/example/counter-function.html)
273283

274284
### Caveats
275285

example/counter-function.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
},
2929

3030
// declare callback Subjects
31-
observableMethods: { muchMore:'muchMore$', minus:'minus$'}, // ['muchMore','minus'] as equal
31+
observableMethods: {
32+
muchMore: 'muchMore$',
33+
minus:'minus$'
34+
}, // equivalent of above: ['muchMore','minus']
3235

3336
subscriptions () {
3437
var count$ = Rx.Observable

0 commit comments

Comments
 (0)