Timer

Instance of a Ticker that is meant to synchronize your repetitive per-frame logic. Some components and utilities internally use this ticker:

import { ticker } from 'oblik'

ticker.on('tick', () => {
    // Called on each requestAnimationFrame()
})

Additionally, you can use the measure() and mutate() hooks to combine multiple DOM reads and writes together, similar to fastdom, and avoid layout thrashing:

import { measure, mutate } from 'oblik'

measure(() => {
    console.log('measure 1')
})

mutate(() => {
    console.log('mutate 1')
})

measure(() => {
    console.log('measure 2')
})

mutate(() => {
    console.log('mutate 2')
})
measure 1
measure 2
mutate 1
mutate 2

As you can see, all measure callbacks are invoked first and then all mutate callbacks. You can also use promises:

measure().then(() => {
    console.log('measure 1')
})

mutate().then(() => {
    console.log('mutate 1')
})
← Tween