Issue by MangelMaxime
Tuesday Nov 27, 2018 at 12:47 GMT
Originally opened as MangelMaxime/Thoth#88
The documentation explain this scenario:
let (formState, formConfig) =
Form<Msg>
.Create(OnFormMsg)
.AddField(
BasicInput
.Create("firstname")
.WithDefaultView()
)
.Build()
So caching formConfig is possible directly.
But if you have something like:
let createForm (userInfo : UserInfo) =
Form<Msg>
.Create(OnFormMsg)
.AddField(
BasicInput
.Create("firstname")
.WithValue(userInfo.Firstname)
.WithDefaultView()
)
.Build()
Then you formConfig isn't cached by default. Current solution is to use a mutable variable to store the formConfig:
let mutable formConfig = Unchecked.defaultof<Types.Config<Msg>>
// Then to init the form
let (state, config) =
createForm currentUser userInfo
formConfig <- config
let (formState, formCmd) =
Form.init formConfig state
Which isn't perfect. We should make formConfig cached by default and probably handle by the library in a special spaces.
One thing to take care is to destroy an old formConfig that is not useful anymore.
Tuesday Nov 27, 2018 at 12:47 GMT
Originally opened as MangelMaxime/Thoth#88
The documentation explain this scenario:
So caching
formConfigis possible directly.But if you have something like:
Then you
formConfigisn't cached by default. Current solution is to use amutablevariable to store theformConfig:Which isn't perfect. We should make
formConfigcached by default and probably handle by the library in a special spaces.One thing to take care is to
destroyan oldformConfigthat is not useful anymore.