-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field enhancers #217
Comments
SpecificationGeneral statements
Technical
export default createField({
enhancers: [enhancer1, enhancer2, ...]
})(FieldComponent);
import { applyEnhancer } from 'react-advanced-form';
import enhancer1 from 'react-advanced-form/enhancers/enhancer1';
import enhancer2 from 'react-advanced-form/enhancers/enhancer2';
import { Input } from '...';
const CreditCardInput = applyEnhancer(enhancer1, enhancer2, ...)(Input); |
UpdatePerformed a very basic PoC to see how this would behave. So far settled with the interceptors approach, where each essential field even could be intercepted and changed by enhancers. This means the introduction of an abstraction layer above the field updates on the form level, to prevent the event payload mutations within custom callback methods (enhancers apply transformations at the very end of the field update cycle, which is form update handlers). I need to think more about this approach, there may be more efficient solution to this. |
Considering #216 in the future scope, enhancers must be implemented in a way to work for both formful and formless fields. That means, that the interception of certain field events may be moved to the I am not sure how I see this change. Interception on a Another solution is to handle interception point at a different place depending on the formless status of a field. This way enhacers of formful fields would intercept events on a form level, which is proper, and formless fields would have the interception logic on a |
UpdateInterception of dispatched events' data was made possible via Observable.fromEvent(...)
.map(eventData => this.interceptEventData(eventName, eventData))
.subscribe(func); Technically speaking, there is no interception as such, but a mapping of incoming events to the listener passed through the array of interceptors (remapers). This works great on a form-centric interception concept, but is questionable whether this is going to be a solution for formless fields. |
Since field enhancers are most likely to land in |
This proposal is obsolete and must not be implemented. Please use |
What
I suggest to add the possibility to extend the form or field components using enhancers.
Why
There are a lot of great features planned for the next release of RAF. However, I don't want to ship even great things in a mandatory manner. The end developer may not need those features like formatting or masks, but will be forced to download them within the source files.
How
Instead, I suggest to add the middleware support. I imagine it working in two scenarios.
Create field with enhancers
Apply enhancers to the existing field
Keynotes
createField
high-order componentThe text was updated successfully, but these errors were encountered: