Fork me on GitHub
#hyperfiddle
<
2024-02-25
>
Vincent20:02:24

What is bindx 😄 ?

Vincent21:02:07

I was under the impression that using binding would make available a variable to all nested-scope fns below/contained within e.g.

(e/defn BigEasyApp []
 (e/server 
  (binding [this-is-a-server-database (get-that-database)]
   (e/client
    (SomeHeader.)
    (SomeContent.)
    (SomeFoot.)))))

but inside 
SomeFoot []

gotta explicitly refer to `this-is-a-server-database`

so therefore, gotta pass `this-is-a-server-database`  in args??? <
pass this in args
`this-is-a-server-database
` results in unserializable reference transfer. so maybe the error is with me, i need to keep the server-tint on the database reference all the way down somehow?

euccastro23:02:23

Try (e/def this-is-a-server-database) at the namespace level? Then you don't need to pass it. This is how e.g. db connections are defined in the tutorials.

Dustin Getz01:02:27

bind the database value in dynamic scope to an e/def, make sure to bind it on the server, and never ever touch it from the client. don’t pass it as an arg to anything except for passing it to clojure in final query, and make sure you do that on the server

Vincent22:02:00

This might be an insane question, but is there a way to ensure that arguments are only passed in server-tint or client-tint ? (CoolSiteMain. (e/server just-on-the-server) (e/client just-on-the-client)) ?