forked from boranton/testcafe-workshop
add code splitting 💔 😻
This commit is contained in:
parent
6abc8c04cb
commit
b306ad39af
@ -1,5 +1,4 @@
|
||||
import {subscribe, getTodo} from '../todo'
|
||||
import renderGraph from './render'
|
||||
|
||||
let graphArea
|
||||
const unsubscribe = {
|
||||
@ -20,7 +19,7 @@ function toggleGraph() {
|
||||
graphArea = document.createElement('div')
|
||||
document.body.querySelector('.graph-area-container').appendChild(graphArea)
|
||||
const {storage} = getTodo()
|
||||
renderGraph(graphArea, storage)
|
||||
loadAndRenderGraph(graphArea, storage)
|
||||
updateTodoSubscription()
|
||||
updateStoreSubscription(storage)
|
||||
return true
|
||||
@ -34,7 +33,7 @@ function updateTodoSubscription() {
|
||||
unsubscribe.todo = subscribe(function onTodoUpdate() {
|
||||
const {storage} = getTodo()
|
||||
updateStoreSubscription(storage)
|
||||
renderGraph(graphArea, storage)
|
||||
loadAndRenderGraph(graphArea, storage)
|
||||
})
|
||||
}
|
||||
|
||||
@ -43,6 +42,12 @@ function updateStoreSubscription(store) {
|
||||
unsubscribe.store()
|
||||
}
|
||||
unsubscribe.store = store.subscribe(function onStoreUpdate() {
|
||||
renderGraph(graphArea, store)
|
||||
loadAndRenderGraph(graphArea, store)
|
||||
})
|
||||
}
|
||||
|
||||
function loadAndRenderGraph(node, store) {
|
||||
System.import('./render').then(({default: renderGraph}) => {
|
||||
renderGraph(node, store)
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user