pinafore/routes/_components/timeline/LazyTimeline.html

37 lines
1.0 KiB
HTML
Raw Normal View History

2018-01-19 09:51:51 +01:00
<div class="lazy-timeline">
2018-01-31 07:21:31 +01:00
{{#await importTimeline}}
2018-01-19 09:51:51 +01:00
{{then constructor}}
<:Component {constructor} :timeline />
2018-01-19 09:51:51 +01:00
{{catch error}}
2018-01-31 06:57:41 +01:00
<div>Component failed to load. Try refreshing! {{error}}</div>
2018-01-19 09:51:51 +01:00
{{/await}}
2018-01-15 08:24:27 +01:00
</div>
<style>
2018-01-19 09:51:51 +01:00
.lazy-timeline {
2018-01-15 08:24:27 +01:00
width: 100%;
2018-01-19 09:51:51 +01:00
min-height: 60vh;
}
2018-01-15 08:24:27 +01:00
</style>
<script>
2018-01-28 01:35:44 +01:00
import { importTimeline } from '../../_utils/asyncModules'
2018-01-28 22:09:39 +01:00
import { store } from '../../_store/store'
2018-03-13 04:58:45 +01:00
import { scheduleIdleTask } from '../../_utils/scheduleIdleTask'
2018-01-15 08:24:27 +01:00
export default {
oncreate() {
let instanceName = this.store.get('currentInstance')
let timeline = this.get('timeline')
this.store.set({currentTimeline: timeline})
this.store.setForTimeline(instanceName, timeline, {runningUpdate: false})
},
store: () => store,
2018-01-15 08:24:27 +01:00
data: () => ({
2018-03-13 04:58:45 +01:00
importTimeline: importTimeline().then(timeline => {
return new Promise((resolve) => {
// make column-switching more responsive by delaying this load
scheduleIdleTask(() => resolve(timeline))
})
})
2018-01-31 07:21:31 +01:00
})
2018-01-15 08:24:27 +01:00
}
</script>