   sub.subscribe(log)
   sub.onNext(4)
 
-backpressureDemos = () ->
+app.demos.behaviours = () ->
+  sub = new Rx.BehaviorSubject(42)
+  # same as `sub = new Rx.ReplaySubject(1); sub.onNext(42)`
+  sub.onNext(2)
+  sub.onNext(3)
+  sub.subscribe(log)
+  sub.onNext(4)
+
+app.demos.backpressure = () ->
   source = Observable.range(0, 10).timeInterval().controlled()
   source.subscribe(logWith("controlled:"))
   source.request(4)
   source.request(4)
 
-
 onload = ->
   init_ui()
-  mouseMoveDemo()
+  app.demos.mouseMove()
   init_websockets()
-  #replayDemo()
   #log("--")
-  #behavioursDemo()
-  #backpressureDemos()
-  #timerDemo()
-#  toAsyncDemo()
-
+  #app.demos.behaviours()
+  #app.demos.replay()
+  #app.demos.backpressures()
+  #app.demos.timer()
+  #app.demos.toAsync()
+#
 window.addEventListener("load", onload, false)


init_ui = ->
  component = R.div {},
    RequestsWidget({})

  app.uiRoot = React.renderComponent(component, document.getElementById('app'));


  Observable.fromEvent(document, 'click')
    .subscribe ->
      timerOn = !timerOn
      if timerOn
        console.log("timer on")
      else
        console.log("timer off")
      timerSwitch.onNext(timerOn)

stackTrace = () -> new Error().stack
app.demos.toAsync = () ->
  f = (arg) ->
    "async: #{arg} #{stackTrace()}"
  fasync = Observable.toAsync(f)
  Observable.interval(1000).flatMap(fasync).subscribe(log)

app.demos.replay = () ->
  sub = new Rx.ReplaySubject()
  # bufferSize, windowSize, scheduler
  sub.onNext(2)
