mikesol / purescript-deku

A PureScript web UI framework
https://purescript-deku.surge.sh/
Apache License 2.0
123 stars 12 forks source link

modifyState #116

Closed jerbaroo closed 5 months ago

jerbaroo commented 5 months ago
setX /\ x <- useState

A modify state function would be useful from time to time, where x is an object with a few fields.

modifyState :: (a -> a) -> Effect Unit
jerbaroo commented 5 months ago

Suggested pattern:

e.g.

      setCountry /\ country <- useState userRemote.country
      setCert /\ cert <- useState userRemote.cert
      setName /\ name <- useState userRemote.name
      let userLocal =
            (\country' cert' name' ->
              {country: country', cert: cert', name: name'})
            <$> country <*> cert <*> name