Error in LiveView docs?

I’m not sure if I’m just misunderstanding or if perhaps I’m missing something but it appears the example found here Phoenix.LiveView — Phoenix LiveView v0.20.2 presumes an already existing Thermostat module and a user id system? Is it not meant to be followed along? The prefacing language makes it sound like it can be followed along if desired:

Before writing your first example, make sure that Phoenix LiveView is properly installed. If you are just getting started, this can be easily done by running mix phx.new my_app --live . The phx.new command with the --live flag will create a new project with LiveView installed and configured. Otherwise, please follow the steps in the installation guide before continuing.

Please tell me if I’m just confused or if perhaps I missed something but it’s a little frustrating trying to follow along with the official documentation to be met with something like this lol. Thanks in advance.

I think that is a side effect of the docs being semi-extracted/written in tandem from a few tutorials at some point. I remember there being one that was explicitly about controlling a thermostat. I think view that section of the docs as more broadly explaining the “general idea” at first. Read through it, accept that it might not all make 100% sense then come back to it after playing around.

I know that doesn’t feel great to read as a new user.

These might help:

This seems to provide a good first-run tutorial, skim reading it: Getting Started with Phoenix LiveView, It’s from 2020, so some things have changed in LV 0.17 but they shouldn’t effect you running through it. *see note

This video and post (Chris McCord - Keynote: Phoenix LiveView - Interactive Apps without Javascript - ElixirConf EU 2019 - YouTube and https://dockyard.com/blog/2018/12/12/phoenix-liveview-interactive-real-time-apps-no-need-to-write-javascript) might make the examples a bit clearer as I think the docs were probably initially written at the same time, but they are kind of out dated now, from 2018.

My advice might be to run through the pragmatic studio tutorial to “get a feel for it” in a guided way, then re-read that opening in the docs to solidify your understanding of how those bits fit together, then post back with anything that doesn’t make sense.

* The changes in 0.17 are mostly the HEEX templates and new ways to run callbacks “on mount”. This covers a lot about heex and functional components for when you get to it: Phoenix.LiveView.Helpers — Phoenix LiveView v0.17.7 and Reuse markup with function components and slots · Fly

2 Likes