UNPKG

react-native-esc-pos-printer

Version:

An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android

34 lines (33 loc) 789 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.monitorPrinter = monitorPrinter; function wait(ms) { return new Promise(resolve => { setTimeout(resolve, ms); }); } function monitorPrinter(printer, listener, interval = 5000) { let isMonitoring = true; async function performMonitor() { await printer.addQueueTask(async () => { try { await printer.connect(); } catch (error) {} const status = await printer.getStatus(); listener(status); await printer.disconnect(); return status; }); await wait(interval); if (isMonitoring) { await performMonitor(); } } performMonitor(); return () => { isMonitoring = false; }; } //# sourceMappingURL=monitorPrinter.js.map