This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aatree (3)
- # alda (8)
- # avi (21)
- # beginners (37)
- # boot (193)
- # cbus (1)
- # cider (29)
- # cljs-dev (8)
- # cljsjs (3)
- # cljsrn (20)
- # clojure (76)
- # clojure-dev (13)
- # clojure-miami (20)
- # clojure-portugal (2)
- # clojure-russia (220)
- # clojure-sg (2)
- # clojurebridge (5)
- # clojurescript (94)
- # community-development (14)
- # conf-proposals (110)
- # core-async (12)
- # cursive (12)
- # datascript (6)
- # datomic (14)
- # dirac (72)
- # emacs (49)
- # hoplon (86)
- # jobs (33)
- # jobs-discuss (1)
- # ldnclj (6)
- # lein-figwheel (1)
- # off-topic (56)
- # om (139)
- # onyx (29)
- # pedestal (17)
- # proton (23)
- # re-frame (45)
- # reagent (35)
- # ring-swagger (4)
- # test-check (1)
- # testing (8)
- # yada (11)
@puzzler: the anonymous cell is not GC'd because it references (and is referenced by)
history. but yes you can use
destroy-cell! to disconnect a cell from every other so that it can be GC'd
hey, was wondering how you approach live reloading while keeping state with hoplon apps. I've found a sample of
on-jsload to refresh the whole page, but that's too aggressive as all of the state gets discarded
was thinking it would be enough to trigger the
(html ...) snippet reload
on-jsload, but can't find a good way to do that
defonce is one way, another way is to keep state you want to persist in a "storage atom"
https://github.com/alandipert/hoplon-contacts-demo/blob/master/src/index.cljs.hl has an example of the local-storage way
I was using the
hack, but this throws away defonces
(defn refresh  (set! (.-href (.-location js/window)) (.-href (.-location js/window))))
then the page reloads when source changes
well, if I have an index.hl page and something that it depends on, upon changing the dependency ns the sources get sent to the browser but the page isn't re-rendered
(html... ) into
(defn render ) and calling
(defn refresh  (. js/hoplon.app_pages._index_DOT_html render)
(boot-reload :on-jsload 'app/refresh)
interesting, i haven't needed to do that yet
strange. Maybe I'm managing my state differently than you do? I have a
(defelem sheet ..) in a separate ns and several instances of it in the
index.cljs.hl. Index ns also holds the state for all of the
sheets, which it passes down to the
Hmm. I’m experiencing weird stuff with
*session*. Say boot is running, and I’ve done something to place a value in
*session* (like logging in). When I refresh the page, that value i placed in
*session* disappears. However, when I restart boot, that value is there. Refreshing again makes it as if
*session* has no value. Does anyone have an idea of what’s happening?
@levitanong: I add a check when the page loads which populates cells if session already has values such as a user token
@flyboarder: Even if I do a
js/setInterval, polling the server for the session every 200ms, the session appears to contain no values, even if it should. Maybe I’m doing something wrong. 😛
@flyboarder: I’ve also added an
add-watch to monitor the
*session* cell whenever it changes, but it triggers only when i start up boot. 😦 When I log in and log out, the
add-watch doesn’t trigger. So I’m at a loss. o_O
hmm, so session is always empty? are you sure you are setting a value 😛
Are you running the hoplon chat demo @levitanong ?
@flyboarder: Session has a value when i load boot. So it’s like, it works as expected only upon a fresh
boot dev. 😆
@laforge49: admittedly, I’m not. I’m trying to adapt the principles in the chat demo onto my app. I’ll be cloning that repo just to make sure though.
@levitanong: how are you setting the new session values?
can you println and see if it is set on the server when you expect it?
(swap! *session* assoc :user value)
okay @flyboarder will do!
@flyboarder: Yeah, the swap is working it seems. When I sign in, session is populated.
@laforge49: So theoretically it should take some time before session is updated on the server, yeah? And that would mean that if I have a
js/setInterval, sooner or later it should work. But it doesn’t 😞
not. You add values on the server side and those values are subsequently represented to the server with each request.
the only way the values can disappear is if you update session yourself. Perhaps by executing the login code at an inappropriate time.
Perhaps you can put a println in the server code at every point where you update session?
@laforge49: @flyboarder: Welp, Just tried running the chat demo, and it’s working as expected, so it’s gotta be my code.
I often have problems finding a bug until I am convinced that it is in my own code.
@levitanong: So the session is updated when you login, we confirmed that
are you trying to get these values in your app client-side?
i think the issue is confusion around the session cell, it is a server cell, so the value is not client side
Well, what I meant is, client-side, on load, I run a
which should return the session data
as in the castra-chat demo
right and that should set a local client side cell with a value
hmm @laforge49 I’m not sure I follow...
@levitanong: @laforge49: I have to run but i think laforge49 can help you sort this now
You update session with a session id on login. And then later use the session id to get the app session-specific data.
Thanks for your time, @flyboarder! Have a great day
you too, ill be around later
@laforge49: I thought session id was a specifically castra-notify thing 😮
but the concept of a session id is pretty common. this is because the session needs to be kept small since it is passed constantly back and forth between the client and server.
Given a session id, then the app server side can identify the larger dataset that is specific to the client.
Note that the lifecycle of the contents of session and the app's session data are different. The app's data disapears when the server goes down, but the data in session does not.
Okay, I’m beginning to see… so the problem I’m facing is happening because every time I refresh the page, the server is using a new session ID because i’m not keeping track of it?
ah, hmmm… I’m basing my app off the castra chat demo though, not the castra notify chat demo.
in that case, would the session id still be a possible cause for my problem?
if you understand how things work and what your code is doing, then everything gets simple. Getting there is not always simple.
that is true 😛
so play with castra chat demo. put in print statements on both client and server side. And develop a good understanding of what's happening. THEN review your code.
Okay, got it
thanks, @laforge49! I really appreciate you taking the time to help me
Well, pass it forward, hmm? I'm a newbie myself and get LOTS of help. What goes around, comes around. And clojure is a GREAT community.