                    (ifn? node)
                    (node path))))
 
-(defn path->signal-fn [path]
+(defn- path->signal-fn [path]
       (if-let [f (path->derived-signal-fn path)]
               f
               #(default-signal-fn path)))
 
-(defn path->signal [path]
+(defn- path->signal [path]
       (if-let [signal (active-signals path)]
               signal
               (make-derived path (path->signal-fn path))))
 
-(defn activate-signal [path signal]
+(defn- activate-signal [path signal]
       (set! active-signals (assoc active-signals path signal)))
 
-(defn deactivate-signal [path]
+(defn- deactivate-signal [path]
       (set! active-signals (dissoc active-signals path)))
 
-(defn reference [path]
+(defn- reference [path]
       (SignalReference. path))
+
+(defn- reagent-subscribe [path]
+       (ReagentSubscription. (path->signal path) {}))
+
+(defn make-base [parent]
+      (let [base (BaseSignal. parent #{})]
+           (-add-watch parent base
+                       (fn [_ old-val new-val]
+                           (if (not= old-val new-val)
+                             (-refresh-children base))))
+           base))
+
+(defn register-derived-signal-fn [path f]
+      (set! registered-derived-signal-fns
+            (assoc-in registered-derived-signal-fns path f)))
+
+(defn register-default-signal-fn [f]
+      (set! default-signal-fn f))
+
+(defn get-in-atom-signal-fn [atom]
+      (let [base (make-base atom)]
+           (fn [path]
+               (get-in @base path))))
 
 (defn subscribe [path]
       (let [sub (ManualSubscription. (path->signal path))]

                        (when (empty? watches)
                              (-remove-child signal this))))

(defn make-base [parent]
      (let [base (BaseSignal. parent #{})]
           (-add-watch parent base
                       (fn [_ old-val new-val]
                           (if (not= old-val new-val)
                             (-refresh-children base))))
           base))

(defn make-derived [path f]
      (let [derived (DerivedSignal. path f nil -1 #{} #{})]
           (-refresh derived)
           (activate-signal path derived)
           derived))

(defn add-refresh-queue [signal depth]
      (if-let [depth-queue (refresh-queue depth)]
              (set! refresh-queue
                    (assoc refresh-queue depth (conj depth-queue signal)))
              (set! refresh-queue
                    (assoc refresh-queue depth #{signal}))))

(defn remove-refresh-queue [signal depth]
      (let [depth-queue (refresh-queue depth)]
           (if (= 1 (count depth-queue))
             (set! refresh-queue (dissoc refresh-queue depth))
             (set! refresh-queue
                   (assoc refresh-queue depth (disj depth-queue signal))))))

(defn enqueue-refresh [signals]
      (doseq [signal signals]
             (add-refresh-queue signal (-get-depth signal))))

(defn refresh []
      (while (seq refresh-queue)
             (doseq [depth-queue (vals refresh-queue)]
                    (doseq [signal depth-queue]
                           (remove-refresh-queue signal (-get-depth signal))
                           (-refresh signal)))))

(defn run-with-deref-capture [signal]
      (if capturing?
        (let [child signal-being-captured
              childs-captured captured-parents]


(defn unsubscribe [sub]
      (-unsubscribe sub))

(defn query [path]
      (let [sub (subscribe path)
