holochain / holochain-proto

Holographic storage for distributed applications -- a validating monotonic DHT "backed" by authoritative hashchains for data provenance (a Ceptr sub-project)
http://holochain.org
GNU General Public License v3.0
877 stars 143 forks source link

clojurescript support for zomes #658

Open thedavidmeister opened 6 years ago

thedavidmeister commented 6 years ago

clojurescript:

it seems like there should be some way to get from cljs to go, even if it's a two step process like clojurescript -> es5 -> go

awb99 commented 5 years ago

It would be awesome to develop clojurescript apps wirh holochain. Wirh reagent the react redux development really looses all the unnecessary overhead.

thedavidmeister commented 5 years ago

@awb99 in the new version of holochain over here https://github.com/holochain/holochain-rust

we are using wasm for zomes

atm this basically means "use rust" but if clj ever ports to wasm we will be ready for it

we are making an effort to minimise the amount of code that is required in zome code in general (macros, design choices, etc.)

a long time ago i made a very simple javelin integration https://github.com/thedavidmeister/javelin-holochain

(defn function-cell
 [& {:keys [zome function params interval]}]
 (j/with-let [c (j/cell nil)]
  (let [t (j/cell nil)
        tick (j/cell 0)
        next! #(swap! tick inc)]
   (j/formula-of
    [zome function params tick]
    (assert (spec/valid? :holochain.zome/zome zome))
    (assert (spec/valid? :holochain.zome/function function))
    (assert (spec/valid? (spec/nilable :holochain.zome/params) params))
    (.clearTimeout js/window @t)
    (reset! t nil)
    (ajax.core/POST
     (str "/" (clojure.string/join  "/" ["fn" zome function]))
     {:handler
      (fn [r]
       (.clearTimeout js/window @t)
       (when interval
        (reset! t (h/with-timeout interval (next!))))
       (reset! c (js->clj (.parse js/JSON r))))
      :error-handler
      (fn [e]
       (taoensso.timbre/error e))
      :params params
      :format :json})))))

it relies on polling

this could probably be revived and improved for the rust version pretty easily (i'm planning to at some point, but you could look at it too!)

reagent atoms should work very similarly to javelin cells IIRC