evancz / elm-architecture-tutorial

How to create modular Elm code that scales nicely with your app
https://guide.elm-lang.org/
BSD 3-Clause "New" or "Revised" License
4.17k stars 738 forks source link

Effects::Random Section Requires Subscription Section to Compile #122

Closed stevensonmt closed 4 years ago

stevensonmt commented 6 years ago

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.

process-bot commented 6 years ago

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.

bbkane commented 6 years ago

I also ran into this issue

bbkane commented 6 years ago

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
evancz commented 4 years ago

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!