EffectSchedulerOptions
See source codeTable of contents
interface EffectSchedulerOptions {}
Properties
scheduleEffect
optional
scheduleEffect is a function that will be called when the effect is scheduled.
It can be used to defer running effects until a later time, for example to batch them together with requestAnimationFrame.
scheduleEffect?: (execute: () => void) => void
Example
let isRafScheduled = false
const scheduledEffects: Array<() => void> = []
const scheduleEffect = (runEffect: () => void) => {
scheduledEffects.push(runEffect)
if (!isRafScheduled) {
isRafScheduled = true
requestAnimationFrame(() => {
isRafScheduled = false
scheduledEffects.forEach((runEffect) => runEffect())
scheduledEffects.length = 0
})
}
}
const stop = react('set page title', () => {
document.title = doc.title,
}, scheduleEffect)
Parameters
Name | Description |
---|---|
| A function that will execute the effect. |
Prev
ComputedOptionsNext
Reactor