code cleanup

This commit is contained in:
Nolan Lawson 2018-02-25 11:20:40 -08:00
parent 3f5f016c32
commit 62d7166b39
4 changed files with 25 additions and 26 deletions

View file

@ -1,4 +1,5 @@
{{#if props}} {{#await asyncProps}}
{{then props}}
<PseudoVirtualListItem :component <PseudoVirtualListItem :component
:props :props
:key :key
@ -10,20 +11,15 @@
:height :height
on:scrollToPosition on:scrollToPosition
/> />
{{/if}} {{/await}}
<script> <script>
import PseudoVirtualListItem from './PseudoVirtualListItem.html' import PseudoVirtualListItem from './PseudoVirtualListItem.html'
export default { export default {
async oncreate() {
let makeProps = this.get('makeProps')
let key = this.get('key')
if (makeProps) {
let props = await makeProps(key)
this.set({props: props})
}
},
components: { components: {
PseudoVirtualListItem PseudoVirtualListItem
},
computed: {
asyncProps: async (makeProps, key) => makeProps && makeProps(key)
} }
} }
</script> </script>

View file

@ -187,6 +187,10 @@
let instanceName = this.store.get('currentInstance') let instanceName = this.store.get('currentInstance')
let timelineName = this.get('timeline') let timelineName = this.get('timeline')
let handleItemIdsToAdd = () => { let handleItemIdsToAdd = () => {
let itemIdsToAdd = this.get('itemIdsToAdd')
if (!itemIdsToAdd || !itemIdsToAdd.length) {
return
}
mark('handleItemIdsToAdd') mark('handleItemIdsToAdd')
let scrollTop = this.get('scrollTop') let scrollTop = this.get('scrollTop')
let shouldShowHeader = this.store.get('shouldShowHeader') let shouldShowHeader = this.store.get('shouldShowHeader')

View file

@ -1,24 +1,20 @@
{{#if props}} {{#await asyncProps}}
<VirtualListItem :component {{then props}}
:offset <VirtualListItem :component
:props :offset
:key :props
:index :key
/> :index
{{/if}} />
{{/await}}
<script> <script>
import VirtualListItem from './VirtualListItem' import VirtualListItem from './VirtualListItem'
export default { export default {
async oncreate() {
let makeProps = this.get('makeProps')
let key = this.get('key')
if (makeProps) {
let props = await makeProps(key)
this.set({props: props})
}
},
components: { components: {
VirtualListItem VirtualListItem
},
computed: {
asyncProps: async (makeProps, key) => makeProps && makeProps(key)
} }
} }
</script> </script>

View file

@ -3,11 +3,13 @@
// for a good breakdown of the concepts behind this. // for a good breakdown of the concepts behind this.
import Queue from 'tiny-queue' import Queue from 'tiny-queue'
import { mark, stop } from './marks'
const taskQueue = new Queue() const taskQueue = new Queue()
let runningRequestIdleCallback = false let runningRequestIdleCallback = false
function runTasks (deadline) { function runTasks (deadline) {
mark('scheduleIdleTask:runTasks()')
while (taskQueue.length && deadline.timeRemaining() > 0) { while (taskQueue.length && deadline.timeRemaining() > 0) {
taskQueue.shift()() taskQueue.shift()()
} }
@ -16,6 +18,7 @@ function runTasks (deadline) {
} else { } else {
runningRequestIdleCallback = false runningRequestIdleCallback = false
} }
stop('scheduleIdleTask:runTasks()')
} }
export function scheduleIdleTask (task) { export function scheduleIdleTask (task) {