Skip to content
scalive
Menu
ConnectingLiveReconnectingOffline
GitHub
c

BrowserEvents

class BrowserEvents[+Msg]

The events that browser JavaScript pushes to a LiveView or LiveComponent, each with the message it becomes.

A hook's this.pushEvent(name, payload) reaches the LiveView, and this.pushEventTo(target, name, payload) reaches the component that renders target. The payload is decoded as the event's type, and the message then goes through event hooks and handleMessage, like a binding's message. A payload that does not decode is logged and consumed without changing the model. Build it with on, as in BrowserEvents.on(CopyResultEvent)(Msg.CopyFinished(_)).on(ScrollEvent)(Msg.Scrolled(_)).

Type parameters

Msg

the messages the events become

Defined by scalive.BrowserEvents. View source (scalive/api/src/scalive/BrowserEvent.scala:89-106)

Methods1

on

def on[A, M >: Msg](event: BrowserToServerEvent[A])(message: A => M)(using evidence$1: zio.json.JsonDecoder[A]): BrowserEvents[M]

Receives event as the message that message builds from its decoded payload.

This form adds it to the events already declared. It throws IllegalArgumentException when an event with the same name is already declared.

Defined by scalive.BrowserEvents.on. View source (scalive/api/src/scalive/BrowserEvent.scala:95-102)

def on[A, Msg](event: BrowserToServerEvent[A])(message: A => Msg)(using evidence$1: zio.json.JsonDecoder[A]): BrowserEvents[Msg]

Receives event as the message that message builds from its decoded payload.

This form starts the declarations with it, like none.on.

Defined by scalive.BrowserEvents.on. View source (scalive/api/src/scalive/BrowserEvent.scala:117-119)