Open MangelMaxime opened 4 years ago
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.
Comment by nojaf Friday Jan 11, 2019 at 08:56 GMT
Would it be an option to have the State implement an interface?
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
Issue by nojaf Friday Jan 11, 2019 at 07:29 GMT Originally opened as https://github.com/MangelMaxime/Thoth/issues/120
Looking at Select, RadioButton and Textarea.
They all have the same
let private validate
andlet private isValid
. Perhaps some functions could be extracted and added to a module for easy re-use?