rleibman / scalajs-reconnecting-websocket   1.2.1

MIT License GitHub

Utilities for interacting with websockets in scalajs

Scala versions: 2.12
Scala.js versions: 0.6

scalajs-reconnecting-websocket

Utilities for interacting with websockets in scalajs

install

Add the following to your sbt build definition

libraryDependencies += "net.leibman" %%% "reconnecting-websocket" % "1.2.0"

Usage:

Super simple, just instantiate in your app an instance of the ReconnectingWebsocket:

	val ws = new ReconnectingWebsocket(s"wss://${window.location.host}/processStatusUpdate",
	debug = true,
  	onMessage = { event 
		val msg = read[ProcessUpdateMessage](event.data.toString)
      	println(s"Websocket: We got a message! ${msg}")
      	refresh.runNow()
  })