View

com.alecdorrington.client.views.View
abstract class View

Base class for all views, using Laminar. Each view corresponds to a distinct page (i.e. at a unique URL) of the website.

Every view must be explicitly exported with JSExportTopLevel so that it appears in main.js and can be served to the user. For example:

import scala.scalajs.js.annotation.JSExportTopLevel

@JSExportTopLevel("IndexView")
object IndexView extends View:
 // ...

The appropriate view for each page is selected based on the name injected into the page template by the server.

Override content to specify the contents of the page. Reactive DOM elements can be imported with:

import com.raquo.laminar.api.L.{*, given}

Attributes

Experimental
true
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object IndexView

Members list

Value members

Abstract methods

protected def content: Base

The contents of this page, specified with reactive DOM elements from Laminar.

The contents of this page, specified with reactive DOM elements from Laminar.

Attributes

Example
 import com.raquo.laminar.api.L.{*, given}
 def content = div(
   h1("Welcome to my website!"),
   p("We're still getting set up here... Stay tuned!"),
 )

Concrete methods

final def show(rootName: String = ...): Unit

An instruction to render this view inside the root div of the given name. This method is side-effecting, and should only be called once per page during initialisation.

An instruction to render this view inside the root div of the given name. This method is side-effecting, and should only be called once per page during initialisation.

Value parameters

rootName

The name of the root element (default = "root"). The contents of this view will be inserted here.

Attributes