mwg API
    Preparing search index...

    Class LoadQueue

    Runs named, weighted asynchronous work while exposing truthful loading progress.

    Tasks run in order, which makes dependency ordering explicit and leaves a game free to start independent work concurrently inside one task. A task that cannot measure itself simply never calls report, so consumers can display an indeterminate current stage instead of inventing a percentage.

    import { LoadQueue } from '@datamoc/mw_games/core';

    const queue = new LoadQueue();
    queue.add({ id: 'tileset', run: async () => { await loadTileset(); } });
    queue.add({ id: 'sounds', weight: 2, run: async (ctx) => {
    await loadSounds((fraction) => ctx.report(fraction));
    }});

    queue.changed.add((snapshot) => console.log(snapshot.status, snapshot.completed));
    await queue.start();

    declare function loadTileset(): Promise<void>;
    declare function loadSounds(onProgress: (fraction: number) => void): Promise<void>;
    Index
    changed: Signal<LoadSnapshot> = ...
    • asks the current task to stop; cancellation is cooperative

      Returns void

    • clears failure/cancellation state and task progress for a new attempt

      Returns void

    • starts queued work and resolves only after every task succeeds

      Returns Promise<void>