2 ms·
Re. performance - Electric v2 is already faster than alternatives for many kinds of apps (not all). We expect v3 to be so fast that it can express apps that are
by dustingetz 2y ago
Re. performance - Electric v2 is already faster than alternatives for many kinds of apps (not all). We expect v3 to be so fast that it can express apps that are outright impossible with alternatives. The robotics observability IDE in the talk, for example, as well as Hyperfiddle itself.
Re. server caching – Electric (being reactive) auto memoizes all scopes, even on the server. (The essence of reactive programming is a time/space tradeoff - cache more things to minimize recomputation later.) For example, in the virtual scroll demo from the talk, the database query runs once and is retained in memory, so that scrolling simply indexes over the memoized collection:
(defn window [xs offset limit]
(subvec (vec xs) ; fast cast
(Math/max offset 0)
(Math/min (+ offset limit) (count xs))))
(e/defn Window [query! offset limit]
(e/server
(let [xs ($ e/Offload #(query!))] ; retain and reuse xs as offset changes
[(count xs) (e/diff-by identity (window xs offset limit))])))
Regarding client caching - it's basically the same. Hoist the value you want to save to be above the conditional that is disposing it. If that doesn't work, use an atom.