electric icon indicating copy to clipboard operation
electric copied to clipboard

Undesired reference transfer caused by eager let and sited lambdas

Open dustingetz opened this issue 3 years ago • 2 comments

We don't yet know how hard this is to fix; for now you can work around with bindings and careful application

; undesired transfer caused by sequential let
(e/client (let [db (e/server (d/db !conn))] (e/server (do db nil)))

; undesired transfer caused by eager argument passing (?)
(e/defn Foo [db] 
  (e/client 
    ...
    (e/server db)))

(e/server
  (let [db (d/db !conn)]
    (e/client
      ...
      (Foo. (e/server db)))))

dustingetz avatar Aug 07 '22 15:08 dustingetz

This is all but solved by a convention of "calling all p/fns from the server"; we have been running with a server-based entrypoint for months now and the pain has vanished

dustingetz avatar Nov 10 '22 23:11 dustingetz

Full solution (colorless lambdas) is understood and on the roadmap; in the meantime the partial solution (call all electric fns from the server) has in practice eliminated the issue in practice at the application layer. At the electric-ui layer, lack of colorless lambdas is currently forcing overuse of macros for complex widgets like typeahead autocomplete.

dustingetz avatar Feb 26 '23 15:02 dustingetz