+37
-0
lines changedFilter options
+37
-0
lines changed Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import { initAssetRegisters } from './assets'
8
8
import { set, del } from '../observer/index'
9
9
import { ASSET_TYPES } from 'shared/constants'
10
10
import builtInComponents from '../components/index'
11
+
import { observe } from 'core/observer/index'
11
12
12
13
import {
13
14
warn,
@@ -44,6 +45,12 @@ export function initGlobalAPI (Vue: GlobalAPI) {
44
45
Vue.delete = del
45
46
Vue.nextTick = nextTick
46
47
48
+
// 2.6 explicit observable API
49
+
Vue.observable = (obj: any): any => {
50
+
observe(obj)
51
+
return obj
52
+
}
53
+
47
54
Vue.options = Object.create(null)
48
55
ASSET_TYPES.forEach(type => {
49
56
Vue.options[type + 's'] = Object.create(null)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
1
+
import Vue from 'vue'
2
+
3
+
describe('Global API: observable', () => {
4
+
it('should work', done => {
5
+
const state = Vue.observable({
6
+
count: 0
7
+
})
8
+
9
+
const app = new Vue({
10
+
render(h) {
11
+
return h('div', [
12
+
h('span', state.count),
13
+
h('button', {
14
+
on: {
15
+
click: () => {
16
+
state.count++
17
+
}
18
+
}
19
+
}, '+')
20
+
])
21
+
}
22
+
}).$mount()
23
+
24
+
expect(app.$el.querySelector('span').textContent).toBe('0')
25
+
app.$el.querySelector('button').click()
26
+
waitForUpdate(() => {
27
+
expect(app.$el.querySelector('span').textContent).toBe('1')
28
+
}).then(done)
29
+
})
30
+
})
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4