mwg API
    Preparing search index...

    Class Recorder

    Records every action dispatched on a signal, stamped with the current frame.

    In a game the two signals are Input.onAction and Game.onFrame:

    const recorder = new Recorder(Input.onAction, game.onFrame);
    // ...play...
    const saved = serializeReplay(recorder.toJSON());

    The signals are parameters rather than imports so tests can drive a recorder with plain Signal instances instead of a whole Game.

    import { Recorder, Signal, serializeReplay } from '@datamoc/mw_games/core';

    const onAction = new Signal<string>();
    const onFrame = new Signal<number>();

    const recorder = new Recorder(onAction, onFrame);
    onFrame.dispatch(0);
    onAction.dispatch('confirm');

    const saved = serializeReplay(recorder.toJSON());
    recorder.stop();
    Index