add code splitting 💔 😻
This commit is contained in:
parent
6abc8c04cb
commit
b306ad39af
@ -1,5 +1,4 @@
|
|||||||
import {subscribe, getTodo} from '../todo'
|
import {subscribe, getTodo} from '../todo'
|
||||||
import renderGraph from './render'
|
|
||||||
|
|
||||||
let graphArea
|
let graphArea
|
||||||
const unsubscribe = {
|
const unsubscribe = {
|
||||||
@ -20,7 +19,7 @@ function toggleGraph() {
|
|||||||
graphArea = document.createElement('div')
|
graphArea = document.createElement('div')
|
||||||
document.body.querySelector('.graph-area-container').appendChild(graphArea)
|
document.body.querySelector('.graph-area-container').appendChild(graphArea)
|
||||||
const {storage} = getTodo()
|
const {storage} = getTodo()
|
||||||
renderGraph(graphArea, storage)
|
loadAndRenderGraph(graphArea, storage)
|
||||||
updateTodoSubscription()
|
updateTodoSubscription()
|
||||||
updateStoreSubscription(storage)
|
updateStoreSubscription(storage)
|
||||||
return true
|
return true
|
||||||
@ -34,7 +33,7 @@ function updateTodoSubscription() {
|
|||||||
unsubscribe.todo = subscribe(function onTodoUpdate() {
|
unsubscribe.todo = subscribe(function onTodoUpdate() {
|
||||||
const {storage} = getTodo()
|
const {storage} = getTodo()
|
||||||
updateStoreSubscription(storage)
|
updateStoreSubscription(storage)
|
||||||
renderGraph(graphArea, storage)
|
loadAndRenderGraph(graphArea, storage)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +42,12 @@ function updateStoreSubscription(store) {
|
|||||||
unsubscribe.store()
|
unsubscribe.store()
|
||||||
}
|
}
|
||||||
unsubscribe.store = store.subscribe(function onStoreUpdate() {
|
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