Fork me on GitHub
#fulcro
<
2018-05-23
>
beders06:05:19

hi there, I'm just starting with fulcro and am stumbling over this:

(defsc Person [this {:keys [person/name person/age]}]
  (dom/div
    (dom/p "Name: " name)
    (dom/p "Age: " age)))

beders06:05:34

The destructuring of keys looks wrong to me

beders06:05:36

shouldn't it be

beders06:05:54

(defsc Person [this {:keys [:person/name :person/age]}] ... )

beders06:05:21

or is the macro adding some magic here?

myguidingstar06:05:11

@beders it's just normal Clojure destructuring. With let for example (let [{:keys [a/b]} {:a/b 1}] b)

cjmurphy06:05:08

@beders Destructuring works with or without the colons prefixing the keys. My experience is that it is very common to omit the colons, so {:keys [person/name person/age]}, or equivalently {:person/keys [name age]}.

👁️ 4
beders15:05:50

Thank you, I totally missed that when reading about destructuring.

myguidingstar12:05:22

hmm,the realworld app has several article lists that need pagination, i haven't figured out how to choose idents for the pages

myguidingstar12:05:08

article lists like: global articles, personal feed, list of articles by a specific user, list of articles liked by a specific user

myguidingstar12:05:16

[:page/by-id page-number] is insufficient, while the number of such article lists is infinite

chrisblom12:05:16

is there support for server sent events in fulcro? Or are websockets the way to go?

wilkerlucio12:05:08

@thheller I just noticed something weird, I'm running code from the repl, but I decided to rename an input alias, now even after reloading the page, I can't run commands using the new alias, for eg, before I had [com.wsscode.pathom.connect :as p.connect] and then I switched to [com.wsscode.pathom.connect :as pc]

wilkerlucio12:05:29

now, even though I restarted the remote connection to the repl, I can't run things like ::pc/indexes, the reader says it's invalid

wilkerlucio12:05:44

the old name still works, so I'm guessing there is some cache issue going on

thheller12:05:48

how did you change the alias?

wilkerlucio12:05:58

I just changed from the ns require of it

wilkerlucio12:05:06

then reloaded the page

thheller12:05:07

and did you eval that?

wilkerlucio12:05:22

no, I just waited to shadow to compile and reload the actual page (on the browser)

thheller12:05:39

that is odd

wilkerlucio12:05:00

I'm restarting the shadow compilation now

wilkerlucio12:05:04

I think after that it might work

thheller12:05:36

open an issue either way. I'll look into it later and see if I can reproduce

wilkerlucio12:05:13

even after restating, it still not working

wilkerlucio12:05:26

the page loads fine, but its like the REPL is stuck with the old alias

wilkerlucio12:05:42

where I can delete all caching to try making it go away?

thheller12:05:43

yeah I think I know why

thheller12:05:21

just reconnecting the REPL should fix it

wilkerlucio12:05:08

I tried stopping compiling, reconnecting everything, it still stuck

thheller12:05:29

hmm then definitely open an issue please

thheller12:05:52

rm -rf .shadow-cljs/builds/<build-id> wipes all the cache

thheller12:05:05

no idea how that survives the cache though

wilkerlucio12:05:27

maybe because the output doesn't change with the alias change?

wilkerlucio12:05:42

but I changed other things, so the file was recompiled, weird

thheller12:05:46

any change in the file will invalidate the cache

wilkerlucio12:05:07

I'll double check if I can make it work and if I can reproduce it

thheller12:05:14

what error do you get?

thheller12:05:33

and do you get the error in the REPL or in the file?

wilkerlucio12:05:57

Failed to read input: clojure.lang.ExceptionInfo: repl-input.cljs [line 1, col 51] Invalid keyword: ::pc/indexes. {:type :reader-exception, :ex-kind :reader-error, :file "repl-input.cljs", :line 1, :col 51}

thheller12:05:43

did you maybe forgot switching namespaces?

wilkerlucio12:05:51

but I think the REPL restart might had worked, I just realised I forgot to change ns on the second time facepalm

wilkerlucio12:05:10

but the first time I was in the right place for sure

thheller12:05:12

I'll check later. the REPL part I think I can imagine how that might happen.

thheller12:05:02

basically the REPL keeps too much state ouside the compiler env which doesn't get updated when watch recompiles a file

thheller12:05:12

instead it shouldn't keep any state and look in the compiler env

thheller12:05:42

will get to it later

wilkerlucio12:05:13

sure, I'll see if I can reproduce it, but I gotta move in a bit, so I may only be able to do that when I get back home

thheller12:05:03

it probably is a concurrency issue

thheller12:05:23

the REPL does a blocking read with the old aliases

thheller12:05:49

you change the alias but the REPL is still blocking with the old aliases

thheller12:05:06

can't update those since we can't interrupt the read

thheller12:05:37

watch combined with a REPL has many weird issues like this

tony.kay13:05:35

@myguidingstar you want parameters. (load :article-list Article {:params {:list :global :page 1}}). You’ll get those args in the params of the query on the server. If you mean: “how do I take articles that I have one the client and make lists out of them?“, the answer is: you write a mutation that pulls filters/sorts/paginates the entire client table into a new list (of idents) on some display component’s normalized state , potentially caching the entire result on that component for quicker pagination nav. The pagination example in the book also shows how you could cache a sliding window of pages…all sorts of options, but ultimately it is pure rendering, so the state you want to show on the UI either has to exist in the DB, or be dynamically generated by the UI code itself in a derived way from that state.

myguidingstar23:05:36

Thanks. I think the problem is I was fixated to have pages in db roots, while they can just live in a particular screen local

tony.kay13:05:08

@chrisblom websockets is the pre-written support that would give you that