You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 23, 2022. It is now read-only.
From the examples it's not clear to me whether I can reduce the number of Cmds I send out through my port.
My scenario is an onInput handler on a password field to update the model and call a port with the password value to derive some cryptographic keys. Now I don't need to go through the port on every key stroke. Delaying the update the model is weird, because in my view I render input field with the value in the model, i.e. input [value model.value] so if I don't update the model the view will lag behind to the point that it doesn't even work properly. Now I wish I could only go through the port if 250ms have passed after the last onInput event rather than calling the relatively expensive port function each and every time.
I'd appreciate either an example or a statement in the docs whether this is possible and if so, how.
It's clear to me that I can manually keep track of the time and do the accounting on my end. But I'm investigating the solution space now and the more code I can recycle, the happier I will be.
The text was updated successfully, but these errors were encountered:
Hi, your scenario makes sense and this module was not designed with that in mind so it's not immediately obvious how to do it, but possible. This ellie example shows one way to do so. It needs to have an additional message just calling the port command, so that this message can be debounced, instead of calling the port right in the message triggered by onInput.
One remark, if I get some time after 0.19 is out, I would like to switch from a view focused approach to an update focused approach as described in issue #3. This would make cases like yours more natural I think. Also beware of #5 in case that's something important to you.
Happy elm coding,
Cheers
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
From the examples it's not clear to me whether I can reduce the number of Cmds I send out through my port.
My scenario is an
onInput
handler on a password field to update the model and call a port with the password value to derive some cryptographic keys. Now I don't need to go through the port on every key stroke. Delaying the update the model is weird, because in my view I render input field with the value in the model, i.e.input [value model.value]
so if I don't update the model the view will lag behind to the point that it doesn't even work properly. Now I wish I could only go through the port if 250ms have passed after the last onInput event rather than calling the relatively expensive port function each and every time.I'd appreciate either an example or a statement in the docs whether this is possible and if so, how.
It's clear to me that I can manually keep track of the time and do the accounting on my end. But I'm investigating the solution space now and the more code I can recycle, the happier I will be.
The text was updated successfully, but these errors were encountered: