         mult-ch (a/mult read-ch)
         poller (poll/watch-port gpio-port timeout #(a/put! read-ch (read-value gpio-port))) ]
 
-    (when edge (do-set-edge! port edge))
+    #?(:clj (when edge (do-set-edge! port edge))
+       :cljs (js/setTimeout #(when edge (do-set-edge! port edge)) 100))
 
     ; Serialize the write loop
     (go (loop []

  Closeable
  (close! [_]
    (unexport! port)))

(defn open-port
  "Opens a port from which values may be read or written.

          Overrides the default formatter"
  [port & opts]
  (export! port)
  (let [{:keys [digital-result-format from-raw-fn]
         :or {digital-result-format :keyword}} opts
        formatter (or from-raw-fn
                      (partial format-raw-digital digital-result-format))
        filename (value-file port)
        gpio-port (BasicGpioPort. port filename formatter)]
    ; Need to wait for the direction file to be available
    #?(:clj (do
              (Thread/sleep 100)
              (preconfigure gpio-port opts))
       :cljs (do
               (js/setTimeout #(preconfigure gpio-port opts) 100)
               gpio-port))))

(defn- tap-and-wrap-chan [mult-ch out-ch]
  (a/tap mult-ch out-ch)
