Widget.queue
Widget.queue.push(task, options?): Promise<boolean>Widget.queue.clear(): voidPuts a task in the queue. Tasks run one at a time, so two events in a row do not overlap.
Widget.on("Twitch.Follow", ({ user }) => { Widget.queue.push(() => { Widget.dom.text(banner, Widget.t("thanks", { name: user })); banner.classList.add("visible"); return () => banner.classList.remove("visible"); }, { duration: 6 });});- If the task returns a function, it is called when its duration ends: that is where you remove what you added.
options.duration: seconds it lasts (by default,manifest.queue.durationSeconds, which is 5).options.priority: with priority it goes ahead of those with less.options.group: when it starts, the pending tasks of its group are folded into it, and it receives how many infolded.- The task receives
{ folded, signal }.signalis anAbortSignal: check it after every wait, before drawing. - A task lasts at most
manifest.queue.taskLimitSeconds(90 s). With a full queue (manifest.queue.maxPending, 50) the lowest priority is dropped. - The result is
trueif it was shown andfalseif it was dropped, folded or the queue was cleared.
Empties the queue and ends the task being shown: it aborts its signal and its final function still runs.