Welcome to mirror list, hosted at ThFree Co, Russian Federation.

nextTick.js « src « alpinejs « packages « alpinejs - github.com/gohugoio/hugo-mod-jslibs-dist.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e5c0d88cee6d774d79693c08717dbb0e8523a102 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

let tickStack = []

let isHolding = false

export function nextTick(callback) {
    tickStack.push(callback)

    queueMicrotask(() => {
        isHolding || setTimeout(() => {
            releaseNextTicks()
        })
    })
}

export function releaseNextTicks() {
    isHolding = false

    while (tickStack.length) tickStack.shift()()
}

export function holdNextTicks() {
    isHolding = true
}