<commit_before>package code.comet

import java.util.Date
import java.util.concurrent.TimeUnit

import com.casualmiracles.rxlift.Components._
import com.casualmiracles.rxlift.Out
import net.liftweb.common.Full
import net.liftweb.http.CometActor
import net.liftweb.http.js.JsCmd
import rx.lang.scala.Observable

import scala.concurrent.duration.Duration

class Clock extends CometActor {

  override def defaultPrefix = Full("clk")

  // Here is an Observable that will generate a string containing the time every 2 seconds
  val ticker: Observable[String] = Observable.interval(Duration(2, TimeUnit.SECONDS)).map(_ ⇒ new Date().toString)

  // construct a label with the ticker
  val timeLabel: Out[String] = label.run(ticker)

  // send the JsCmds emitted by the label to the actor to send to the UI
  val subscription = timeLabel.jscmd.map(this ! _).subscribe()

  // initial render uses the label's ui
  def render = bind("time" -> timeLabel.ui)

  override def lowPriority : PartialFunction[Any, Unit] = {
    case cmd: JsCmd ⇒ partialUpdate(cmd)
  }

  // important to unsubscribe to subscriptions
  override def localShutdown() = subscription.unsubscribe()
}<commit_msg>added another comment to Clock<commit_after>package code.comet

import java.util.Date
import java.util.concurrent.TimeUnit

import com.casualmiracles.rxlift.Components._
import com.casualmiracles.rxlift.Out
import net.liftweb.common.Full
import net.liftweb.http.CometActor
import net.liftweb.http.js.JsCmd
import rx.lang.scala.Observable

import scala.concurrent.duration.Duration

class Clock extends CometActor {

  override def defaultPrefix = Full("clk")

  // Here is an Observable that will generate a string containing the time every 2 seconds
  val ticker: Observable[String] = Observable.interval(Duration(2, TimeUnit.SECONDS)).map(_ ⇒ new Date().toString)

  // construct a label with the ticker
  val timeLabel: Out[String] = label.run(ticker)

  // send the JsCmds emitted by the label to the actor to send to the UI
  val subscription = timeLabel.jscmd.map(this ! _).subscribe()

  // initial render uses the label's ui
  def render = bind("time" -> timeLabel.ui)

  // receive the JsCmd sent by the above to the ui
  override def lowPriority : PartialFunction[Any, Unit] = {
    case cmd: JsCmd ⇒ partialUpdate(cmd)
  }

  // important to unsubscribe to subscriptions
  override def localShutdown() = subscription.unsubscribe()
}
{'fraction_non_alphanumeric': 0.09098428453267163, 'fraction_numerical': 0.0016542597187758478, 'mean_word_length': 4.3048245614035086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5927312', 'n_tokens_mistral': 739, 'n_tokens_neox': 708, 'n_words': 232}