Revert "add observeSafely()"

it doesn't actually work

This reverts commit 321a90251a.
This commit is contained in:
Nolan Lawson 2018-02-11 14:17:17 -08:00
parent 8dcf72d144
commit c3a82a15bf

View file

@ -32,10 +32,10 @@
export default { export default {
oncreate () { oncreate () {
this.observeSafely('showFooter', showFooter => { this.observe('showFooter', showFooter => {
this.store.setForRealm({showFooter: showFooter}) this.store.setForRealm({showFooter: showFooter})
}) })
this.observeSafely('items', (items) => { this.observe('items', (items) => {
mark('set items') mark('set items')
this.store.setForRealm({items: items}) this.store.setForRealm({items: items})
stop('set items') stop('set items')
@ -44,7 +44,7 @@
}, SCROLL_TO_BOTTOM_DELAY) }, SCROLL_TO_BOTTOM_DELAY)
}) })
this.observeSafely('allVisibleItemsHaveHeight', allVisibleItemsHaveHeight => { this.observe('allVisibleItemsHaveHeight', allVisibleItemsHaveHeight => {
if (allVisibleItemsHaveHeight) { if (allVisibleItemsHaveHeight) {
this.fire('initializedVisibleItems') this.fire('initializedVisibleItems')
} }
@ -52,7 +52,7 @@
let observedOnce = false let observedOnce = false
this.observeSafely('distanceFromBottom', (distanceFromBottom) => { this.observe('distanceFromBottom', (distanceFromBottom) => {
if (!observedOnce) { if (!observedOnce) {
observedOnce = true // TODO: the first time is always 0... need better way to handle this observedOnce = true // TODO: the first time is always 0... need better way to handle this
return return
@ -77,19 +77,6 @@
}, },
// TODO: bug in svelte store, shouldn't need to do this // TODO: bug in svelte store, shouldn't need to do this
allVisibleItemsHaveHeight: ($allVisibleItemsHaveHeight) => $allVisibleItemsHaveHeight allVisibleItemsHaveHeight: ($allVisibleItemsHaveHeight) => $allVisibleItemsHaveHeight
},
ondestroy() {
this.__destroyed = true
},
methods: {
observeSafely(val, callback) {
// TODO: feels like this shouldn't be necessary... bug in Svelte?
this.observe(val, val => {
if (!this.__destroyed) {
callback(val)
}
})
}
} }
} }
</script> </script>