So just to solidify and condense some of the suggestions on here, it seems to be:
- Start with the data (impossible states and make data structures)
- Loading states might be best as custom
type
s - Potentially use non-empty lists …
Or default data in yourSee belowjson
(instead of aMaybe
)?- But
Maybe
types are fine to use, as isMaybe.withDefault
.
Maybe.withDefault
@wolfadex I quite like that approach, do you normally just use it for a string
or do you also use for other data types?
I understand the general idea or FindKeyedShape
, but I can’t quite visualise how that search function might work.
Case
ing on a loading type
…
@ChrisWellsWood I’ve seen this method before of case
ing on your model
for noop
, loading
, loaded
, failed
which makes sense … but could you expand a little on your custom type records? I understand Page
(a title and it’s body), but …
- Why are you naming things
mToken
andtoken
? What do they stand for? - How do you pass your
loaded
data to updatePage
andview
when it’s loaded? (I’m assumingMyPageData
is the decoder?)
Impossible states
@dta Do you personally have any other examples you could add to that line of thought? Simple ones ideally.
What would a Maybe
type look like in the json
?
I’m splitting this out into another question, as it brings up the question how to save and represent a type
in the json file, be it a Maybe
or a type Custom
.