All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hyperscala.examples.basic.RealtimeExample.scala Maven / Gradle / Ivy

package org.hyperscala.examples.basic

import org.hyperscala.examples.Example
import org.hyperscala.html._
import org.hyperscala.html.tag.P
import org.hyperscala.realtime.{Realtime, RealtimeEvent}
import org.hyperscala.web.Webpage

import scala.language.reflectiveCalls

/**
 * @author Matt Hicks 
 */
class RealtimeExample extends Webpage with Example {
  require(Realtime)

  val message = new P
  body.contents += message
  message.contents += new tag.Span(content = "Click the button below.")

  body.contents += new tag.Button(id = "button", content = "Click Me!") {
    clickEvent := RealtimeEvent()

    clickEvent.on {
      case evt => {
        message.contents.replaceWith(new tag.Span(content = f"Button last clicked: ${System.currentTimeMillis()}%tr"))
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy