fix(cardassignment): debounce w/ immediate start
This commit is contained in:
parent
1605b0f7b2
commit
1d6ed99073
@ -15,6 +15,7 @@
|
|||||||
"@odit/license-exporter": "0.2.0",
|
"@odit/license-exporter": "0.2.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "2.1.1",
|
"@sveltejs/vite-plugin-svelte": "2.1.1",
|
||||||
"@types/papaparse": "^5.3.15",
|
"@types/papaparse": "^5.3.15",
|
||||||
|
"@types/underscore": "^1.13.0",
|
||||||
"auto-changelog": "2.5.0",
|
"auto-changelog": "2.5.0",
|
||||||
"prettier": "3.5.3",
|
"prettier": "3.5.3",
|
||||||
"prettier-plugin-svelte": "3.3.3",
|
"prettier-plugin-svelte": "3.3.3",
|
||||||
@ -55,6 +56,7 @@
|
|||||||
"svelte-i18n": "4.0.1",
|
"svelte-i18n": "4.0.1",
|
||||||
"tailwindcss": "^4.1.4",
|
"tailwindcss": "^4.1.4",
|
||||||
"tinro": "0.6.12",
|
"tinro": "0.6.12",
|
||||||
|
"underscore": "^1.13.7",
|
||||||
"validator": "13.15.0",
|
"validator": "13.15.0",
|
||||||
"xlsx": "0.18.5"
|
"xlsx": "0.18.5"
|
||||||
},
|
},
|
||||||
|
16
pnpm-lock.yaml
generated
16
pnpm-lock.yaml
generated
@ -53,6 +53,9 @@ importers:
|
|||||||
tinro:
|
tinro:
|
||||||
specifier: 0.6.12
|
specifier: 0.6.12
|
||||||
version: 0.6.12
|
version: 0.6.12
|
||||||
|
underscore:
|
||||||
|
specifier: ^1.13.7
|
||||||
|
version: 1.13.7
|
||||||
validator:
|
validator:
|
||||||
specifier: 13.15.0
|
specifier: 13.15.0
|
||||||
version: 13.15.0
|
version: 13.15.0
|
||||||
@ -69,6 +72,9 @@ importers:
|
|||||||
'@types/papaparse':
|
'@types/papaparse':
|
||||||
specifier: ^5.3.15
|
specifier: ^5.3.15
|
||||||
version: 5.3.15
|
version: 5.3.15
|
||||||
|
'@types/underscore':
|
||||||
|
specifier: ^1.13.0
|
||||||
|
version: 1.13.0
|
||||||
auto-changelog:
|
auto-changelog:
|
||||||
specifier: 2.5.0
|
specifier: 2.5.0
|
||||||
version: 2.5.0
|
version: 2.5.0
|
||||||
@ -730,6 +736,9 @@ packages:
|
|||||||
'@types/papaparse@5.3.15':
|
'@types/papaparse@5.3.15':
|
||||||
resolution: {integrity: sha512-JHe6vF6x/8Z85nCX4yFdDslN11d+1pr12E526X8WAfhadOeaOTx5AuIkvDKIBopfvlzpzkdMx4YyvSKCM9oqtw==}
|
resolution: {integrity: sha512-JHe6vF6x/8Z85nCX4yFdDslN11d+1pr12E526X8WAfhadOeaOTx5AuIkvDKIBopfvlzpzkdMx4YyvSKCM9oqtw==}
|
||||||
|
|
||||||
|
'@types/underscore@1.13.0':
|
||||||
|
resolution: {integrity: sha512-L6LBgy1f0EFQZ+7uSA57+n2g/s4Qs5r06Vwrwn0/nuK1de+adz00NWaztRQ30aEqw5qOaWbPI8u2cGQ52lj6VA==}
|
||||||
|
|
||||||
adler-32@1.3.1:
|
adler-32@1.3.1:
|
||||||
resolution: {integrity: sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==}
|
resolution: {integrity: sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==}
|
||||||
engines: {node: '>=0.8'}
|
engines: {node: '>=0.8'}
|
||||||
@ -2000,6 +2009,9 @@ packages:
|
|||||||
engines: {node: '>=0.8.0'}
|
engines: {node: '>=0.8.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
underscore@1.13.7:
|
||||||
|
resolution: {integrity: sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==}
|
||||||
|
|
||||||
undici-types@6.21.0:
|
undici-types@6.21.0:
|
||||||
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
|
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
|
||||||
|
|
||||||
@ -2604,6 +2616,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 22.14.1
|
'@types/node': 22.14.1
|
||||||
|
|
||||||
|
'@types/underscore@1.13.0': {}
|
||||||
|
|
||||||
adler-32@1.3.1: {}
|
adler-32@1.3.1: {}
|
||||||
|
|
||||||
agent-base@7.1.1:
|
agent-base@7.1.1:
|
||||||
@ -3888,6 +3902,8 @@ snapshots:
|
|||||||
uglify-js@3.19.3:
|
uglify-js@3.19.3:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
underscore@1.13.7: {}
|
||||||
|
|
||||||
undici-types@6.21.0: {}
|
undici-types@6.21.0: {}
|
||||||
|
|
||||||
unicorn-magic@0.1.0: {}
|
unicorn-magic@0.1.0: {}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
Html5QrcodeScanner,
|
Html5QrcodeScanner,
|
||||||
Html5QrcodeScanType,
|
Html5QrcodeScanType,
|
||||||
Html5QrcodeSupportedFormats,
|
Html5QrcodeSupportedFormats,
|
||||||
Html5QrcodeScannerState,
|
|
||||||
} from "html5-qrcode";
|
} from "html5-qrcode";
|
||||||
|
import { debounce } from "underscore";
|
||||||
|
|
||||||
export let width;
|
export let width;
|
||||||
export let height;
|
export let height;
|
||||||
@ -13,23 +13,17 @@
|
|||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
const debounceFunc = (func, delay) => {
|
const debouncedDispatch = debounce(
|
||||||
let timer;
|
function (decodedText) {
|
||||||
return function (...args) {
|
// console.log("dispatchEvent");
|
||||||
const context = this;
|
dispatch("detect", { decodedText });
|
||||||
clearTimeout(timer);
|
},
|
||||||
timer = setTimeout(() => {
|
500,
|
||||||
func.apply(context, args);
|
true
|
||||||
}, delay);
|
);
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const debouncedDispatch = debounceFunc(function (decodedText) {
|
|
||||||
console.log("dispatchEvent");
|
|
||||||
dispatch("detect", { decodedText });
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
function onScanSuccess(decodedText, decodedResult) {
|
function onScanSuccess(decodedText, decodedResult) {
|
||||||
|
// console.log("onScanSuccess", decodedText);
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
debouncedDispatch(decodedText);
|
debouncedDispatch(decodedText);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user