evancz/elm-architecture-tutorial

Effects::Random Section Requires Subscription Section to Compile

stevensonmt opened this issue · 4 comments

Subscriptions are never added in the text of the tutorial. Without defining main you can compile without the subscriptions section but get an empty view. If you define main as Html.program you have to add the subscriptions section in order to compile but your view is then correct.

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

I also ran into this issue

Ooh, this also seems to affect the next tutorial.

This can be fixed (I think, I'm completely new) by:

adding a main declaration:

main =
  Html.program
    { init = init
    , view = view
    , update = update
    , subscriptions = subscriptions
}

Adding a do-nothing subscription:

subscriptions : Model -> Sub Msg
subscriptions model =
  Sub.none
  

I believe the latest version of https://guide.elm-lang.org/ introduces both main and subscriptions as they appear in programs, if only to mention that we will cover them in more detail soon. Sorry for the trouble!