Fork me on GitHub
#hoplon
<
2015-12-29
>
chromalchemy06:12:35

@raymcdermott: Thanks for putting up the Datomic example, I've been wanting to play with it from Hoplon, but have yet to grok the Castra scaffolding. Examples of adding and updating data are much appreciated!

raymcdermott06:12:29

@mynomoto: I have added the namespace so you should see it in the PR now.

raymcdermott06:12:58

@chromalchemy: still working it out myself but yes those are the examples Iā€™m targetting

laforge4919:12:28

How do I trigger a cell refresh?

laforge4919:12:10

@micha when I get an notification (from notify), I do a swap! on a cell, but I do not see the value refreshed in the browser. How do I trigger that refresh?

micha19:12:39

do you have any formula cells referencing the input cell you called swap! on?

micha19:12:09

and the ui references those?

laforge4919:12:18

(def state (cell= rpc/state))

laforge4919:12:34

(div (text state))

micha19:12:52

that formula is unnecessary, you can just do (def state rpc/state)

laforge4919:12:54

In all other cases I am seeing the update

micha19:12:59

or just use rpc/state

laforge4919:12:04

yes, I was trying that

micha19:12:13

the problem thoudh is that text is a macro

micha19:12:16

expects a string

micha19:12:29

(text "~{rpc/state}")

micha19:12:44

or you can use the :text attribute

micha19:12:51

like (h1 :text rpc/state)

micha19:12:03

or even (h1 rpc/state)

laforge4919:12:33

Still not working. šŸ˜ž

laforge4919:12:59

I see updated state when a message is targeted to it. But not with swap!

micha19:12:15

you can do this to debug: (cell= (pr :state rpc/state))

micha19:12:26

then you should see messages in the js console when it changes

micha19:12:35

but it's possible that the value is not changing

micha19:12:53

you can call swap! all you want, but nothing will propagate unless the value contained in the cell changes

micha19:12:12

using cljs.core/= as the equality test

laforge4919:12:36

I can see the updated value already...

laforge4919:12:15

(defn deactivate-user! [user] (println :deactivate-user user) (println @state) (swap! state (fn [s] (let [user-sessions (:user-sessions s) user-sessions (dissoc user-sessions user) s (assoc s :user-sessions user-sessions)] (println s) s))))

laforge4919:12:31

I'm seeing the updated s in the browser.

micha19:12:25

btw you can use update-in there to advantage

micha19:12:56

(swap! state update-in [:user-sessions] dissoc user)

laforge4919:12:18

yeah, I was having a lot of problems with that line of code for some reason.

laforge4919:12:14

I'll get back to it, but I was dealing with 2 bugs in the same spot

laforge4919:12:33

I dropped my println's and added (cell= (pr :state rpc/state)) and got nada.

laforge4919:12:42

It is not seeing the change

micha19:12:17

the value contained must not be changing

laforge4919:12:18

(cell= (pr :state rpc/state)) shows all the other changes.

laforge4919:12:38

sure looks different when I print s.

laforge4919:12:05

I'll change var names

laforge4919:12:02

no, you are right. not changing.

laforge4919:12:38

everything is fine. destructuring error. Phhhht! šŸ˜„