-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathexample.js
65 lines (61 loc) · 2.09 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* eslint-disable */
document.addEventListener('DOMContentLoaded', function(){
Vue.use(VuePromiseBtn)
Vue.use(bootstrapVue)
const CustomSpinner = Vue.component('custom-spinner', {
template: '<span>...</span>'
})
Vue.component('custom-form', {
template: `<form @submit.prevent="$emit('submit', 'data')">
<p>
<button type="submit">Button Form Submit - Handle Component Event</button>
</p>
</form>`
})
new Vue({
el: '#app',
data: {
currentChain: 0,
currentYear: new Date().getFullYear(),
promiseBtnOptions: {
customComponentLoader: { loader: CustomSpinner },
customHTMLLoader: { loader: '<b>(HTML loader...)</b>' },
},
dataPromise: null,
bootstrapBtnPromise: null,
},
methods: {
incrementChain () {
return this.currentChain++
},
dummyAsyncAction () {
return new Promise((resolve, reject) => setTimeout(resolve, 2000))
},
asyncActionWithArgs ($event, param) {
return () => {
// double return to show that expression to promise can be
return () => {
return this.dummyAsyncAction()
}
}
},
asyncWithPromiseInData (param) {
console.log(param);
this.dataPromise = this.dummyAsyncAction()
},
vueBootstrap (param) {
console.log(param);
this.bootstrapBtnPromise = this.dummyAsyncAction()
},
chain () {
this.currentChain = 1
return this.dummyAsyncAction()
.then(this.incrementChain)
.then(this.dummyAsyncAction)
.then(this.incrementChain)
.then(this.dummyAsyncAction)
.then(() => { this.currentChain = 0 })
}
}
})
});