so im using a bluetooth barcodescanner with my app,
this is the code i use to read its values (works with every barcodescanner in text mode)
i have a page named “list”
window.addEventListener("keypress", function (e) { // barcodescanner input
if (e.keyCode != 13) {
This.barcodeText += e.key; //text gets added
} else {
// do whatever
This.barcodeText = ""; //reset variable
This.router.navigateByUrl('/input');
}
})
the problem arises when i go to the “input” page and then dont touch/click anything and use the barcode scanner again , the listener in the “list” page still receives the input …
this behaviour also holds true for anything else , unless you actually touch the phones display in the new page the old page is still receiving .
this also isnt a racing condition as this holds true even after 30 seconds …
maybe the window object is global(above router) , but then i cant use window at all.
is window.document global too then ???
this information is also critical when you use firestore with subscribe(); then you may use an array index to input data but firestore already updated the array on the recent page in the background and you write to the wrong array slot …
seriously thinking about porting the app to vanilla js + ionic instead of angular. theres so many pits you can fall into with angular routing , this is the second very huge shortcoming ive come across…
1 post - 1 participant