TuneWeb.ExplorerLive (tune v0.1.0)

Main view used in the application. Covers:

  • Search
  • Suggestions
  • Displaying details for artists, albums, etc.
  • Mini player

Mounting and authentication

When mounting, TuneWeb.ExplorerLive uses the session data to start a Spotify session. Note that we use a private function spotify_session/0 to load the appropriate behaviour (for example in tests we use a mock).

mount/3 always loads user profile data, player status and currently available devices, as such information is always displayed irrespectively of the section.

When connected, mount/3 also subscribes to session event for the relevant session id.

Routing

Depending on the route, handle_params/3 dispatches to different internal functions which take care of loading additional data specific for each section.

Events

Events generated by subscriptions are handled in handle_info/2 and primarily take care of updating the socket assigns. When appropriate, changes are forwarded to the progress bar so that it gets updated. This mechanism ensures that:

  • when the same song plays and only elapsed time changes, only the progress bar is re-rendered
  • when the song changes or is played/paused, we also re-render other parts of the UI (e.g. if the currently playing song is visualized in its album's tracklist)

Events generated by the UI are all handled via handle_event/3.

Link to this section Summary

Functions

Callback implementation for Phoenix.LiveView.render/1.

Link to this section Functions

Callback implementation for Phoenix.LiveView.render/1.