Feature request for form level listeners #1306
Replies: 1 comment
-
My apologies, I now realize a pull-request #1261 exists for this feature, which has some difficulties that haven't been solved yet. I suppose that it makes this discussion redundant. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to be able to listen to form events on a form-level basis, so that it's possible to listen to form actions such as
onBlur
from a single location. I am aware that it is technically possible to listen toonChange
by subscribing to the form store state, but this is not possible for the other field actions, even though use cases exist where it's preferred to subscribe toonMount
,onBlur
and to a lesser extentonSubmit
.For this, I expect the the implementation to be relatively easy as the current listener implementation already covers most requirements. The FieldListenerFn already contains a
fieldApi
parameter so that it can easily be deduced which field fires an event, even on a form-level basis.In order to implement this, I believe little more needs to be done than adding a
listeners
attribute to theFormOptions
interface being of the FieldListeners type. Additionally, the form-level listeners events can be fired in their respective functions, for example foronChange
in theFieldApi.setValue
method:If help is required to implement this feature I think I'd be able to contribute. I'm interested to hear whether this a useful feature for this library.
Beta Was this translation helpful? Give feedback.
All reactions