// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
export class IMUEvent {
    #subs = new Set();
    subscribe(fn) {
        this.#subs.add(fn);
        return () => { this.unsubscribe(fn); };
    }
    once(fn) {
        const wrap = (v) => {
            this.unsubscribe(wrap);
            fn(v);
        };
        return this.subscribe(wrap);
    }
    unsubscribe(fn) {
        this.#subs.delete(fn);
    }
    // Push a new event to all subscribers
    push(value) {
        [...this.#subs].forEach((fn) => {
            fn(value);
        });
    }
    clear() {
        this.#subs.clear();
    }
}
const imuEvent = new IMUEvent();
export function getIMUEventEmitter() {
    return imuEvent;
}
//# sourceMappingURL=imu-manager.js.map