How to use microevent - 9 common examples

To help you get started, we’ve selected a few microevent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 6502ts / 6502.ts / src / web / embedded / stellerator / Stellerator.ts View on Github external
fullscreenViaKeyboard: true,
            paddleViaMouse: true,
            pauseViaKeyboard: true,
            pauseViaTouch: true,
            fullscreenViaTouch: true,
            enableGamepad: true,
            resetViaKeyboard: true,

            ...config
        };

        this._emulationService = new EmulationService(workerUrl);

        this.frequencyUpdate = this._emulationService.frequencyUpdate;

        const stateChange = new EventImplementation();
        this._emulationService.stateChanged.addHandler(newState => stateChange.dispatch(this._mapState(newState)));
        this.stateChange = stateChange;

        this._createDrivers();

        this._driverManager.addDriver(this._controlPanel, context =>
            this._controlPanel.bind(context.getControlPanel())
        );
        this._driverManager.bind(this._emulationService);

        this._serviceInitialized = this._emulationService.init().then(undefined, e => {
            console.log(e);
            throw e;
        });
    }
github 6502ts / 6502.ts / src / cli / stella / StellaCLI.ts View on Github external
constructor(fsProvider: FilesystemProviderInterface, protected _cartridgeFile?: string) {
        super(fsProvider);

        this.events.stateChanged = new Event();

        const systemConfigSetupProvider = new SystemConfigSetupProvider(this._stellaConfig);

        this._commandInterpreter.registerCommands({
            run: () => (this._setState(StellaCLI.State.run), 'running...')
        });

        this._runModeCommandInterpreter = new CommandInterpreter({
            stop: () => (this._setState(StellaCLI.State.debug), 'stopped, entered debugger')
        });

        this._setupModeCommandInterpreter = new CommandInterpreter({
            'load-cartridge': this._executeLoadCartridge.bind(this)
        });
        this._setupModeCommandInterpreter.registerCommands(systemConfigSetupProvider.getCommands());
github 6502ts / 6502.ts / src / tools / pool / Pool.ts View on Github external
if (victim._isAvailable) {
            if (this._poolSize > 1) {
                this._pool[victim._poolPosition] = this._pool[this._poolSize - 1];
            }

            this._poolSize--;
        }

        victim._isDisposed = true;

        this.event.dispose.dispatch(victim.get());
    }

    event = {
        release: new Event(),
        dispose: new Event()
    };

    private _pool: Array> = [];

    private _poolSize = 0;
}

namespace Pool {
    export interface FactoryInterface {
        (): T;
    }

    export interface RecycleCallbackInterface {
        (value: T): void;
    }
github 6502ts / 6502.ts / src / cli / AbstractCLI.ts View on Github external
*   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this program; if not, write to the Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

import { Event } from 'microevent.ts';

abstract class AbstractCLI {
    events: AbstractCLI.Events = {
        outputAvailable: new Event(),
        quit: new Event(),
        promptChanged: new Event(),
        prompt: new Event(),
        availableCommandsChanged: new Event()
    };
}

namespace AbstractCLI {
    export interface Events {
        outputAvailable: Event;

        quit: Event;

        promptChanged: Event;

        prompt: Event;
github 6502ts / 6502.ts / src / machine / stella / Bus.ts View on Github external
getLastAddresBusValue(): number {
        return this._lastAddressBusValue;
    }

    private triggerTrap(reason: Bus.TrapReason, message?: string): void {
        if (this.event.trap.hasHandlers) {
            this.event.trap.dispatch(new Bus.TrapPayload(reason, this, message));
        } else {
            throw new Error(message);
        }
    }

    event = {
        trap: new Event(),
        read: new Event(),
        write: new Event()
    };

    private _tia: Tia = null;
    private _pia: Pia = null;
    private _cartridge: CartridgeInterface = null;

    private _lastDataBusValue = 0;
    private _lastAddressBusValue = 0;
}

namespace Bus {
    export const enum TrapReason {
        tia,
        pia,
        cartridge
github 6502ts / 6502.ts / src / machine / stella / Bus.ts View on Github external
getLastAddresBusValue(): number {
        return this._lastAddressBusValue;
    }

    private triggerTrap(reason: Bus.TrapReason, message?: string): void {
        if (this.event.trap.hasHandlers) {
            this.event.trap.dispatch(new Bus.TrapPayload(reason, this, message));
        } else {
            throw new Error(message);
        }
    }

    event = {
        trap: new Event(),
        read: new Event(),
        write: new Event()
    };

    private _tia: Tia = null;
    private _pia: Pia = null;
    private _cartridge: CartridgeInterface = null;

    private _lastDataBusValue = 0;
    private _lastAddressBusValue = 0;
}

namespace Bus {
    export const enum TrapReason {
        tia,
        pia,
        cartridge
    }
github 6502ts / 6502.ts / src / tools / pool / Pool.ts View on Github external
if (victim._isAvailable) {
            if (this._poolSize > 1) {
                this._pool[victim._poolPosition] = this._pool[this._poolSize - 1];
            }

            this._poolSize--;
        }

        victim._isDisposed = true;

        this.event.dispose.dispatch(victim.get());
    }

    event = {
        release: new Event(),
        dispose: new Event()
    };

    private _pool: Array> = [];

    private _poolSize = 0;
}

namespace Pool {
    export interface FactoryInterface {
        (): T;
    }

    export interface RecycleCallbackInterface {
        (value: T): void;
    }
github 6502ts / 6502.ts / src / cli / AbstractCLI.ts View on Github external
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this program; if not, write to the Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

import { Event } from 'microevent.ts';

abstract class AbstractCLI {
    events: AbstractCLI.Events = {
        outputAvailable: new Event(),
        quit: new Event(),
        promptChanged: new Event(),
        prompt: new Event(),
        availableCommandsChanged: new Event()
    };
}

namespace AbstractCLI {
    export interface Events {
        outputAvailable: Event;

        quit: Event;

        promptChanged: Event;

        prompt: Event;

        availableCommandsChanged: Event;
    }
github 6502ts / 6502.ts / src / machine / stella / Bus.ts View on Github external
}

    getLastAddresBusValue(): number {
        return this._lastAddressBusValue;
    }

    private triggerTrap(reason: Bus.TrapReason, message?: string): void {
        if (this.event.trap.hasHandlers) {
            this.event.trap.dispatch(new Bus.TrapPayload(reason, this, message));
        } else {
            throw new Error(message);
        }
    }

    event = {
        trap: new Event(),
        read: new Event(),
        write: new Event()
    };

    private _tia: Tia = null;
    private _pia: Pia = null;
    private _cartridge: CartridgeInterface = null;

    private _lastDataBusValue = 0;
    private _lastAddressBusValue = 0;
}

namespace Bus {
    export const enum TrapReason {
        tia,
        pia,

microevent

event emitter micro library (works in node+browser)

Unknown
Latest version published 13 years ago

Package Health Score

36 / 100
Full package analysis

Popular microevent functions

Similar packages