bahulneel / om-datascript

Make om and datascript play nice
26 stars 1 forks source link

automate binding? #1

Open stephanos opened 9 years ago

stephanos commented 9 years ago

Would it be possible to pass-in some kind of "DataScriptCursor" into a component? Like this:

(defn app-view []
  (reify
    om/IRender
    (render [_]
      (let [count (query q-count)] ; count is a 'DataScriptCursor'
        (dom/div nil
          (dom/h2 nil "Hello World")
          (om/build #(app-counter count) {})))))) ; app-counter receives a 'DataScriptCursor'

Then maybe the manual binding could be removed:

om/IWillMount
(will-mount [_]
  (od/project-onto conn app app-projections))
om/IWillUnmount
(will-unmount [_]
  (od/unproject-from conn app app-projections))

What do you think?

bahulneel commented 9 years ago

Yes, I think this would be possible and considered it in my first pass. Now that I have it working it could make for some handy convenience code.

stephanos commented 9 years ago

I would love to see that :+1: :)