   toEventStream: -> new EventStream(@subscribe)
   toString: -> "Dispatcher"
 
+nop = ->
 empty = (xs) -> xs.length == 0
 head = (xs) -> xs[0]
 tail = (xs) -> xs[1...xs.length]
-
+toEvent = (x) -> if x instanceof Event then x else Jnoid.next x

Jnoid.fromDOM = ($, e)->

Jnoid.fromList = (list)->
  new EventStream( (sink)->
    schedule = (xs) ->
      if empty xs
        sink Jnoid.end()
      else
        push xs
    push = (xs) ->
      reply = sink Jnoid.next head xs
      unless reply == Jnoid.noMore
        schedule tail xs
    schedule list
  )

# Dummy objects for asserting.
# Should not be equal.

Jnoid.end = -> new End()

class Event
  isEnd: -> false
  isInitial: -> false
  isNext: -> false
