Skip to content

Commit ffbe9a9

Browse files
committed
switching to recollect with caches
1 parent 11c2b4e commit ffbe9a9

File tree

5 files changed

+233
-224
lines changed

5 files changed

+233
-224
lines changed

calcit.cirru

+25-18
Original file line numberDiff line numberDiff line change
@@ -3415,6 +3415,18 @@
34153415
|j $ {} (:type :leaf) (:id |rynmbgL-e0r-) (:text |app.server) (:by |root) (:at 1500541255553)
34163416
|r $ {} (:type :expr) (:id |SyTmWlU-xRBZ) (:by nil) (:at 1500541255553)
34173417
:data $ {}
3418+
|yyyr $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1593255050706)
3419+
:data $ {}
3420+
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1593255051068) (:text |[]) (:id |OttYKFkjb7leaf)
3421+
|j $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1593255057574) (:text |recollect.twig) (:id |O0gx3yGjo4)
3422+
|r $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1593255058305) (:text |:refer) (:id |sohOUki0AR)
3423+
|v $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1593255058544)
3424+
:data $ {}
3425+
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1593255058785) (:text |[]) (:id |c-3gYVjH_W)
3426+
|j $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1593255059229) (:text |new-twig-loop!) (:id |VBtDU673Qi)
3427+
|r $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1593255068726) (:text |clear-twig-caches!) (:id |YId1MbC3c)
3428+
:id |0Q0YBi8Cyc
3429+
:id |OttYKFkjb7
34183430
|T $ {} (:type :leaf) (:id |S1AmWe8WgRBW) (:text |:require) (:by |root) (:at 1500541255553)
34193431
|yL $ {} (:type :expr) (:id |HylWRQCh2Z) (:by |root) (:at 1507808200988)
34203432
:data $ {}
@@ -3480,15 +3492,6 @@
34803492
|j $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544855375175) (:text "|\"path") (:id |-m4ZmPN9Dw)
34813493
|r $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544855375739) (:text |:as) (:id |TOQgB9-N2P)
34823494
|v $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544855376714) (:text |path) (:id |I9UuKC2fbr)
3483-
|yyy $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1544725704637) (:id |H3nnNfqC9Pi)
3484-
:data $ {}
3485-
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544725704637) (:text |[]) (:id |HBVGP07xyeQ)
3486-
|j $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544725704637) (:text |recollect.twig) (:id |LfNVnJyIYap)
3487-
|r $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544725704637) (:text |:refer) (:id |wRI-bDev3fi)
3488-
|v $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1544725704637) (:id |pP5aq0_51h0)
3489-
:data $ {}
3490-
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544725704637) (:text |[]) (:id |fN5bGYZvoCz)
3491-
|j $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544725704637) (:text |render-twig) (:id |0m_YETWb2tT)
34923495
|yyx $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1544725704637) (:id |DhV1kziF4nO)
34933496
:data $ {}
34943497
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544725704637) (:text |[]) (:id |xiMoy98TjF1)
@@ -3867,16 +3870,12 @@
38673870
|v $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1544724852267) (:id |CAkC3b628xi)
38683871
:data $ {}
38693872
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |new-store) (:id |qet69uMbYUr)
3870-
|j $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1544724852267) (:id |wzgbfKJf4yS)
3873+
|j $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1544724852267) (:id |FM9Lko1iOn3)
38713874
:data $ {}
3872-
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |render-twig) (:id |gfng3i_RuN3)
3873-
|j $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1544724852267) (:id |FM9Lko1iOn3)
3874-
:data $ {}
3875-
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |twig-container) (:id |yDCLfI7sZY6)
3876-
|j $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |db) (:id |ClDXNR2UT7s)
3877-
|r $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |session) (:id |3xWr3SwYowV)
3878-
|v $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |records) (:id |n7WtF9Wv7_r)
3879-
|r $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |old-store) (:id |mfDxRuATmij)
3875+
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |twig-container) (:id |yDCLfI7sZY6)
3876+
|j $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |db) (:id |ClDXNR2UT7s)
3877+
|r $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |session) (:id |3xWr3SwYowV)
3878+
|v $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |records) (:id |n7WtF9Wv7_r)
38803879
|x $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1544724852267) (:id |qLJDPfYg1MA)
38813880
:data $ {}
38823881
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |changes) (:id |dryXyJZFaUQ)
@@ -3942,6 +3941,10 @@
39423941
|r $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |assoc) (:id |RtJEI2TOLuk)
39433942
|v $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |sid) (:id |LzutOPLyPUJ)
39443943
|x $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1544724852267) (:text |new-store) (:id |9TOGzOT7RCz)
3944+
|x $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1593255041829)
3945+
:data $ {}
3946+
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1593255047538) (:text |new-twig-loop!) (:id |ADpVKOjkRleaf)
3947+
:id |ADpVKOjkR
39453948
|*client-caches $ {} (:type :expr) (:id |S1VrmlLWxAr-) (:by nil) (:at 1500541255553)
39463949
:data $ {}
39473950
|T $ {} (:type :leaf) (:id |HyrB7gIWeCrb) (:text |defonce) (:by |root) (:at 1500541255553)
@@ -4105,6 +4108,10 @@
41054108
:data $ {}
41064109
|T $ {} (:type :leaf) (:id |H13dbl8ZgAB-) (:text |sync-clients!) (:by |root) (:at 1507806907419)
41074110
|j $ {} (:type :leaf) (:id |S1aO-x8bxABZ) (:text |@*reader-reel) (:by |root) (:at 1507829993436)
4111+
|vT $ {} (:type :expr) (:by |B1y7Rc-Zz) (:at 1593255076396)
4112+
:data $ {}
4113+
|T $ {} (:type :leaf) (:by |B1y7Rc-Zz) (:at 1593255076725) (:text |clear-twig-caches!) (:id |BTUqyb3x4D)
4114+
:id |mJ_7cI3g2
41084115
|*reader-reel $ {} (:type :expr) (:id |SkrNzg8-eAHb) (:by nil) (:at 1500541255553)
41094116
:data $ {}
41104117
|T $ {} (:type :leaf) (:id |HkU4MeUWgRrb) (:text |defonce) (:by |root) (:at 1500541255553)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"devDependencies": {
2828
"feather-icons": "^4.28.0",
2929
"node-notifier": "^7.0.1",
30-
"shadow-cljs": "^2.10.12",
30+
"shadow-cljs": "^2.10.13",
3131
"source-map-support": "^0.5.19",
3232
"url-parse": "^1.4.7"
3333
}

shadow-cljs.edn

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
:cache-blockers #{cumulo-util.build}
44
:dependencies [
55
[mvc-works/hsl "0.1.2"]
6-
[mvc-works/shell-page "0.1.10"]
6+
[mvc-works/shell-page "0.1.13"]
77
[mvc-works/ws-edn "0.1.3"]
8-
[cumulo/recollect "0.5.0"]
8+
[cumulo/recollect "0.6.0-a2"]
99
[cumulo/reel "0.2.0"]
1010
[cumulo/util "0.1.12"]
11-
[respo "0.12.2"]
12-
[respo/ui "0.3.14"]
11+
[respo "0.12.3"]
12+
[respo/ui "0.3.15-a1"]
1313
[respo/alerts "0.5.5"]
1414
[respo/message "0.3.6"]
1515
[respo/feather "0.1.1"]

src/app/server.cljs

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
[cumulo-util.core :refer [id! repeat! unix-time! delay!]]
1212
[app.twig.container :refer [twig-container]]
1313
[recollect.diff :refer [diff-twig]]
14-
[recollect.twig :refer [render-twig]]
1514
[ws-edn.server :refer [wss-serve! wss-send! wss-each!]]
16-
[favored-edn.core :refer [write-edn]])
15+
[favored-edn.core :refer [write-edn]]
16+
[recollect.twig :refer [new-twig-loop! clear-twig-caches!]])
1717
(:require-macros [clojure.core.strint :refer [<<]]))
1818

1919
(defonce *client-caches (atom {}))
@@ -58,13 +58,14 @@
5858
records (:records reel)
5959
session (get-in db [:sessions sid])
6060
old-store (or (get @*client-caches sid) nil)
61-
new-store (render-twig (twig-container db session records) old-store)
61+
new-store (twig-container db session records)
6262
changes (diff-twig old-store new-store {:key :id})]
6363
(when config/dev? (println "Changes for" sid ":" changes (count records)))
6464
(if (not= changes [])
6565
(do
6666
(wss-send! sid {:kind :patch, :data changes})
67-
(swap! *client-caches assoc sid new-store)))))))
67+
(swap! *client-caches assoc sid new-store)))
68+
(new-twig-loop!)))))
6869

6970
(defn render-loop! []
7071
(when (not (identical? @*reader-reel @*reel))
@@ -100,5 +101,6 @@
100101

101102
(defn reload! []
102103
(println "Code updated.")
104+
(clear-twig-caches!)
103105
(reset! *reel (refresh-reel @*reel initial-db updater))
104106
(sync-clients! @*reader-reel))

0 commit comments

Comments
 (0)