The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

434429 (3) [Avatar] Offline
#1
I just finished the 2nd chapter and I was a bit puzzled by the way you introduce messages:

{ operation = "SELECT_PHOTO", data = "2.jpeg" }


I don't understand why we are using this Redux-like format, I think that the operation field is overhead typical from javascript, where you can't match against the constructor and then the match on strings is needed.

Wouldn't it be more idiomatic using the type constructor with a named payload, like:

type Msg =
  SelectPhoto url


Or is there a specific reason for this? Like slowly introducing more advanced concepts?

Thanks!
Pietro

rtfeldman (60) [Avatar] Offline
#2
Or is there a specific reason for this? Like slowly introducing more advanced concepts?


Yep! In Chapter 3 we introduce union types and then refactor to use them. smilie
Richard Haven (8) [Avatar] Offline
#3
Would it help to have a footnote or symbol to indicate "Refactored later" ?

It will keep the wonks from scribbling in the early chapters
stephenc (22) [Avatar] Offline
#4
I agree with Richard Haven on this one. Some kind of symbol in a box pre-warning of soon-to-be-explained best practises.