Skip to content
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

Consider helper functions for custom form input #9

Open
MangelMaxime opened this issue Nov 8, 2019 · 3 comments
Open

Consider helper functions for custom form input #9

MangelMaxime opened this issue Nov 8, 2019 · 3 comments

Comments

@MangelMaxime
Copy link
Contributor

Issue by nojaf
Friday Jan 11, 2019 at 07:29 GMT
Originally opened as MangelMaxime/Thoth#120


Looking at Select, RadioButton and Textarea.

They all have the same let private validate and let private isValid.
Perhaps some functions could be extracted and added to a module for easy re-use?

@MangelMaxime
Copy link
Contributor Author

Comment by MangelMaxime
Friday Jan 11, 2019 at 08:41 GMT


I tried to extract them to a module but I couldn't find a way to write it in a type safe way.

In F# record can't inherit from another so I can't be sure that the State provide by the user got Validators property. I could use JavaScript interop using ? operator but I am not sure yet.

@MangelMaxime
Copy link
Contributor Author

Comment by nojaf
Friday Jan 11, 2019 at 08:56 GMT


Would it be an option to have the State implement an interface?

@MangelMaxime
Copy link
Contributor Author

Comment by MangelMaxime
Friday Jan 11, 2019 at 10:43 GMT


Perhaps, I don't really know :)

I am sure the state can't be a Class otherwise elmish debugger or console log would not work. As it's using Thoth.Json to generate the JSON and because classes can't be converted by default due to limitation in Fable reflection.

We can test using an interface and see if this don't had too much noise/code duplication etc. And also, if we can pass F# type system when using interface to represent the state :)

I mean today we are boxing the field state in order to store all the field states in a single list. source code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant