Nuxt/examples/dynamic-components/js/messages.js

28 lines
855 B
JavaScript
Raw Normal View History

2017-09-21 20:27:30 +00:00
export const messages = [
2017-07-08 23:44:59 +00:00
{ component: 'vText', data: 'Welcome to the <b>Dynamic Component</b> demo!' },
{ component: 'vImage', data: 'https://placeimg.com/350/200/animals' },
{ component: 'vCode', data: 'var a = 1;\nvar b = 2;\nb = a;' },
2017-09-21 20:27:30 +00:00
{
component: 'vChart',
data: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
2017-10-20 06:45:34 +00:00
datasets: [
{
label: 'Activity',
backgroundColor: '#41b883',
data: [40, 20, 12, 39, 10, 40, 39, 50, 40, 20, 12, 11]
}
2017-09-21 20:27:30 +00:00
]
}
},
2017-10-20 06:45:34 +00:00
{ component: 'vText', data: 'End of demo 🎉' }
2017-07-08 23:44:59 +00:00
]
2017-10-31 13:43:55 +00:00
async function streamMessages(fn, i = 0) {
2017-07-08 23:44:59 +00:00
if (i >= messages.length) return
await fn(messages[i])
setTimeout(() => streamMessages(fn, i + 1), 1500)
2017-07-08 23:44:59 +00:00
}
2017-10-20 06:45:34 +00:00
export default streamMessages