elm-form icon indicating copy to clipboard operation
elm-form copied to clipboard

Define and expose a type alias for the callback argument in `withOnSubmit`

Open derrickbeining opened this issue 2 years ago • 5 comments

This signature for withOnSubmit looks like this:

withOnSubmit : ({ fields : List ( String, String ), method : Method, action : String, parsed : Validated error parsed } -> msg) -> Options error parsed input oldMsg extras -> Options error parsed input msg extras

This anonymous record has to be re-defined by consumers of this package any time they want to use this function:

{ fields : List ( String, String )
, method : Method
, action : String
, parsed : Validated error parsed 
}

It would be convenient if a type alias was defined and exposed for this that we could reuse when defining a message constructor to be used with withOnSubmit.

derrickbeining avatar Dec 04 '23 14:12 derrickbeining

This anonymous record has to be re-defined by consumers of this package any time they want to use this function.

I'm not sure I understand, why does a type alias need to be defined to use the function?

dillonkearns avatar Dec 04 '23 17:12 dillonkearns

Because when I'm defining my Msg type, I have to do

type Msg 
    = OnSubmit
        { action : String
        , method : Form.Method
        , fields : List ( String, String )
        , parsed : Form.Validated String PersonalInfo
        }

It would be nice to be able to just do something like

type Msg 
    = OnSubmit Form.OnSubmitArgs

derrickbeining avatar Jan 08 '24 19:01 derrickbeining