0.0.3 • Published 2 years ago

@pvorona/scheduling v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Task scheduling

import { scheduleTask, PRIORITY } from '@pvorona/scheduling'

let windowWidth: number | undefined

scheduleTask(() => {
  windowWidth = window.innerWidth
}, PRIORITIES.READ)

scheduleTask(() => {
  document.body.innerText = `Window width is ${windowWidth}px`
}, PRIORITIES.WRITE)

// Window width is 900px

Tasks are scheduled to be executed before the next animation frame. Execution order is based on the priority: READ, COMPUTE, WRITE, FUTURE.