Been working on an app - just finished it. Well, two apps, a keyboard and a reminder thingy.
Anyway, keyboard uses drag events to get input, app takes touch inputs. Keyboard returns a promise which eventually resolves with the typed text. Works great. Only issue is what I think is the following race condition (determined with super high tech debug strategy console.logs):
User submits their text input using a drag gesture (on release, b == 0)
Promise resolves. Keyboard is unloaded.
App receives text, applies it, renders appropriate UI and menu
Lingering touch event caused by the same finger motion that resulted in event #1 resolves
App presses whatever button is now under where the user's finger was in step 1, leading them to a different menu or input than intended.
I can solve this pretty trivially by adding like a 50ms timeout between the user drag input release and the promise resolving, but I was wondering if anyone else has run into this issue?
I'm wondering if there's a potential enhancement out there to clear unresolved events when setUI() or equivalent is called, so that you don't have a bangle input event that starts while one UI is loaded and resolves when another UI is loaded.
EDIT: Another viable workaround might be to have submit operate on the 'touch' event instead. Might be a little cleaner than a setTimeout but less obvious to the reader.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Been working on an app - just finished it. Well, two apps, a keyboard and a reminder thingy.
Anyway, keyboard uses
drag
events to get input, app takestouch
inputs. Keyboard returns a promise which eventually resolves with the typed text. Works great. Only issue is what I think is the following race condition (determined with super high tech debug strategy console.logs):b == 0
)touch
event caused by the same finger motion that resulted in event #1 resolvesI can solve this pretty trivially by adding like a 50ms timeout between the user drag input release and the promise resolving, but I was wondering if anyone else has run into this issue?
I'm wondering if there's a potential enhancement out there to clear unresolved events when
setUI()
or equivalent is called, so that you don't have a bangle input event that starts while one UI is loaded and resolves when another UI is loaded.EDIT: Another viable workaround might be to have submit operate on the 'touch' event instead. Might be a little cleaner than a setTimeout but less obvious to the reader.
EDIT: EDIT: Found this potentially relevant-but-not-precisely-identical github issue.
https://github.com/espruino/BangleApps/issues/2754#issuecomment-1547357991