Skip to content

Commit f47ef07

Browse files
committed
indent
1 parent b9f6144 commit f47ef07

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Rx, hasRx, warn } from '../util'
22

33
/**
4-
* @name vue.prototype.$createObservableFunction
4+
* @name Vue.prototype.$createObservableFunction
55
* @description Creates an observable from a given function name.
66
* @param {String} functionName Function name
77
* @param {Boolean} [passContext] Append the call context at the end of emit data?
@@ -23,7 +23,7 @@ export default function createObservableFunction (functionName, passContext) {
2323
return
2424
}
2525

26-
if(vm[functionName] !== undefined){
26+
if (vm[functionName] !== undefined) {
2727
warn(
2828
'Potential bug: ' +
2929
`Method ${functionName} already defined on vm and has been overwritten by $createObservableFunction.` +
@@ -32,26 +32,25 @@ export default function createObservableFunction (functionName, passContext) {
3232
)
3333
}
3434

35-
let creator = function (observer) {
36-
35+
const creator = function (observer) {
3736
vm[functionName] = function () {
38-
let args = Array.from(arguments);
39-
if(passContext){
40-
args.push(this);
41-
observer.next(args);
42-
}else{
37+
const args = Array.from(arguments)
38+
if (passContext) {
39+
args.push(this)
40+
observer.next(args)
41+
} else {
4342
if (args.length <= 1) {
44-
observer.next(args[0]);
43+
observer.next(args[0])
4544
} else {
46-
observer.next(args);
45+
observer.next(args)
4746
}
4847
}
49-
};
50-
return function() {
51-
delete vm[functionName];
52-
};
53-
};
48+
}
49+
return function () {
50+
delete vm[functionName]
51+
}
52+
}
5453

55-
//Must be a hot stream otherwise function context may overwrite over and over again
56-
return Rx.Observable.create(creator).share();
54+
// Must be a hot stream otherwise function context may overwrite over and over again
55+
return Rx.Observable.create(creator).share()
5756
}

test/test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ test('$eventToObservable() with lifecycle hooks', done => {
318318
})
319319
})
320320

321-
322321
test('$createObservableFunction() with no context', done => {
323322
const vm = new Vue({
324323
created () {
@@ -337,7 +336,7 @@ test('$createObservableFunction() with no context', done => {
337336
test('$createObservableFunction() with muli params & context', done => {
338337
const vm = new Vue({
339338
created () {
340-
this.$createObservableFunction('add',true)
339+
this.$createObservableFunction('add', true)
341340
.subscribe(function (param) {
342341
expect(param[0]).toEqual('hola')
343342
expect(param[1]).toEqual('mundo')
@@ -347,6 +346,6 @@ test('$createObservableFunction() with muli params & context', done => {
347346
}
348347
})
349348
nextTick(() => {
350-
vm.add('hola','mundo')
349+
vm.add('hola', 'mundo')
351350
})
352351
})

0 commit comments

Comments
 (0)