import { balDevice } from "../device";
import { SingleSubject } from "../types/signal";
import { BalSwipeListener } from "./swipe.listener";
export class BalSwipeSubject extends SingleSubject {
    constructor(options = { mobileOnly: false }) {
        super((observer, data) => {
            if (data) {
                observer.swipeListener(data);
            }
        });
        this.options = options;
        this.listener = new BalSwipeListener();
    }
    attach(observer) {
        if ((this.options.mobileOnly === true && balDevice.isMobile) || this.options.mobileOnly !== true) {
            super.attach(observer);
            this.listener.connect(observer.el);
            this.listener.add(info => super.notify(info));
        }
    }
    detach() {
        super.detach();
        this.listener.disconnect();
    }
}
