This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
Howdy. I've been impressed with Electric (and Hyperfiddle before that) for a long time. But I'm just now starting to think about using it in anger. Is it possible to compile the server side of things to ClojuresScript rather than Clojure?
nodejs server target is not a supported configuration, it is possible of course but needs a commercial use to justify (and fund maintenance)
Am I right in thinking that the following should throw Pending
until my-db-query
returns?
(e/server (e/offload #(my-db-query <args>)))
I’m seeing Pending
thrown on initial load. When the values in <args>
change, my-db-query
is called but Pending
is not thrown.it depends- for pending to be thrown on the client, the client needs to be the origination of the change. in other words, if something changes on the server, the client is not aware of that and pending cannot be thrown
Ah, maybe I understand… Do I need to be calling the server within a callback on the client (as happens in the Chat demo)? If I’m making my server call as a result of a watch on an atom (even if that’s on the client), then I won’t get pending?
think of it this way- in a multiplayer chat app, if the message came from someone else’s tab, there can’t be a pending in your tab because your tab doesn’t know about the change yet. you’ll only learn about the new chat message when it arrives, at which point it’s too late for a Pending. you only see pending when the load is in response to your own event
Note we have an experimental e/offload-task
• e/offload
: throws Pending until the first result is available, further results are streamed in without seeing further Pendings. Pending -> value -> value -> value -> ....
• e/offload-task
: throws Pending until first result is available. Then throw Pending again while the task re-runs. Pending -> value -> Pending -> value -> ....