   ([init] (input init (gen-topic)))
   ([init topic]
    (map->Signal {:init init
-                 :message-emitter [:events (event-relay topic)]})))
+                 :subscribed-topics #{topic}})))
 
 (defn constant
   [x]

  (fresh? [_] false))

(defprotocol SignalProtocol
  (sources [s]))

(defn signal?
  [x]
  (satisfies? SignalProtocol x))

(defrecord Signal
  [init message-emitter event-emitter]
  SignalProtocol
  (sources [_]
    (into #{}
          (comp (filter identity)
                (mapcat (comp flatten vector first))
                (filter signal?))
          [message-emitter event-emitter])))

(defn- event-relay
  [topic]
  (fn [prev event]
    (if (= topic (:topic event))


(defn async
  [source]
  (let [topic source]
    (map->Signal {:init (:init source)
                  :event-emitter [source (fn [message]
                                           (when (fresh? message)
                                             (:value message)))]
                  :subscribed-topics #{topic}})))

(defn mergeseq
  [sigs]
