using non-input element with send-server-request breaks
stevebuik opened this issue · comments
same issue as the earlier non-input fix: the send-server-request fn assumes an input event is being fired.
I can call set-values before calling send-server-request so it just needs to have a way to get key and value without the event.
this is also reproducible using a checkbox input that calls send-server-request in it's on-change handler
the built-in change handler correctly reads the new checkbox value but send-server-request borks when trying to call .getAttribute.
Also happens with non-input elements. In my case, same rc-slider as in the prev issue.
I'm happy to fix and send PR, just starting the discussion here. Or happy to help fix another way if that's faster.
Yeah, I see you are right! What do you suggest if we don't pass the event down?
not sure tbh. In my case, the state has already been updated so key/value are not needed for up to date values.
the only other need is then throttle/de-bounce which uses the key.
maybe a fallback for reading key/value from event using special paths which the caller populates? (not very elegant)
or allow a cljs map to be passed in as the event arg. then dispatch using map? to read key/value and fallback to existing event read path? again, not elegant
Yeah I was thinking about the second one.. mm I'll give it some thought and see if I can come up with other solutions as well
Could you pull send-server-request apart into 2 fns? first one updates state and 2nd uses the state to debounce/throttle/call http-fn.
then I could call set-values or handle-change to replace the first fns updates and still use the 2nd fn for the real server request.
Yup sounds like a good solution. Will decouple the two over the weekend thanks :)