How to use the @abandonware/noble.once function in @abandonware/noble

To help you get started, weโ€™ve selected a few @abandonware/noble 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 thegecko / webbluetooth / src / adapter.ts View on Github external
this.init(() => {
            this.deviceHandles = {};
            function stateCB() {
                if (this.state === true) {
                    // Noble doesn't correctly match short and canonical UUIDs on Linux, so we need to check ourselves
                    // Continually scan to pick up all advertised UUIDs
                    noble.startScanning([], true, this.checkForError(errorFn, completeFn));
                } else {
                    errorFn("adapter not enabled");
                }
            }

            if (noble.state === "unknown" || noble.state === "poweredOff") {
                // tslint:disable-next-line:no-string-literal
                noble["once"]("stateChange", stateCB.bind(this));
            } else {
                stateCB.call(this);
            }
        });
    }
github thegecko / webbluetooth / src / adapter.ts View on Github external
public getEnabled(completeFn: (enabled: boolean) => void) {
        function stateCB() {
            completeFn(this.state);
        }

        if (noble.state === "unknown" || noble.state === "poweredOff") {
            // tslint:disable-next-line:no-string-literal
            noble["once"]("stateChange", stateCB.bind(this));
        } else {
            stateCB.call(this);
        }
    }