Fork me on GitHub
#fulcro
<
2018-01-23
>
tony.kay04:01:00

The routers are stand-alone components that can appear anywhere in the tree.

currentoor04:01:50

oh i see, thanks

currentoor04:01:47

also, i noticed the routers (vial trial and error) the routers and the keywords they use to key screens have a sort of naming convention

tony.kay04:01:21

There are naming conventions, but Im’ not sure which ones you refer to 🙂

currentoor04:01:18

it looks like the router screen keys have to be the name of the route plus a suffix that matches the router name

currentoor04:01:49

otherwise i kept getting an unknown route message on the screen

currentoor04:01:42

:status-report has to have -report at the end to work

currentoor04:01:57

is that expected or am i just crazy? 😅

tony.kay04:01:01

not quite right

currentoor04:01:55

i was able to rename :status-report to :summary-dashboard but i had to rename the router as well

tony.kay04:01:17

no, the ident matters

tony.kay04:01:28

so, a router is just a component that controls another union

tony.kay04:01:36

(unions have to have a join…so you need 2)

tony.kay04:01:45

The union “routes” based on the ident

tony.kay04:01:10

so, when you change the name of the route, the ident function has to be updated to generate the correct ident to match

tony.kay04:01:22

Make sense?

tony.kay04:01:41

(defrouter A
   (ident …)
   :x X)

tony.kay04:01:04

the X component has to generate an ident that starts with [:x ...]

tony.kay04:01:11

it’s on Untangled, but it explains how you can use unions to do routing…the current routing implementation is based upon this.

currentoor04:01:58

so in that example in the book, i could just change all the instances of :status-report to :foobar and nothing else and it would work?

currentoor05:01:18

i’ll watch that video, thanks for helping 😄

tony.kay05:01:51

link queries destructure as if they were a normal join kw

cjmurphy05:01:55

I came across this looking at the state of Fulcro Template, seeing a field join in the table :main, that was not an ident but a map.

tony.kay05:01:54

I’m not sure what you’re asking

tony.kay05:01:30

:id could be passed into props

tony.kay05:01:38

as can :current-user

tony.kay05:01:46

both were queried for…

cjmurphy05:01:00

Yes I changed it to id.

cjmurphy05:01:04

:main {:page {:id :main, :current-user {:uid 2, :name "Joe", :email "<mailto:[email protected]|[email protected]>", :password "letmein"}}},

tony.kay05:01:17

that is props, right?

cjmurphy05:01:28

See how current-user is not an ident.

tony.kay05:01:49

I do…but are you trying to show me props or a normalized state db

cjmurphy05:01:08

id was not in props, I guess both should be. I am showing you state.

tony.kay05:01:33

I do not see why :current-user is there at all

tony.kay05:01:44

should not be there at all, even as an ident

tony.kay05:01:52

unless it got mis-initialized

cjmurphy05:01:13

I think so too (now) - it s/not be there but it is. I was thinking it s/be an ident. But there's no need for a field if it is a link, I think.

tony.kay05:01:38

correct. I may have mistakenly put it there on a load

tony.kay06:01:01

unless you’re looking at something you think is state, but is really denormalized

cjmurphy06:01:14

From (get-state). Is it supposed to be in the table denormalized?

cjmurphy06:01:23

... if it is a link.

tony.kay06:01:35

I don’t see anything wrong in the code. what get-state?

cjmurphy06:01:01

In user, to see the state, instead of using fulcro Inspect.

tony.kay06:01:29

you mean you’re directly dumping the state atom from a REPL?

tony.kay06:01:34

So, I’ve never noticed it…I guess I could start it up and look…

tony.kay06:01:45

When I look at state, I only see :id in main

cjmurphy06:01:13

Good idea if that state map-entry for the :main table looks wrong to you. A denormalized :current-user. Why is it there? I haven't altered any code, except putting (get-state) in cljs.user.

tony.kay06:01:19

:current-user is at root, and is an ident pointing at the user table.

tony.kay06:01:51

OH…you’re using the utilities from the book or something.

cjmurphy06:01:51

But it is also in the :main table.

tony.kay06:01:55

those run db->tree

tony.kay06:01:10

You give it a component, yes

cjmurphy06:01:55

Every user.cljs has a dump of some sort to see the state, just looking at the state.

tony.kay06:01:56

ok…well, I’m not sure what is going wrong for you then. The state is correct on a pristine template when looking at it via Fulcro Inspect.

cjmurphy06:01:56

Have you logged in as Joe?

cjmurphy06:01:03

Need to do that.

tony.kay06:01:20

I did log in, yes…not as joe…as the other predefined one

cjmurphy06:01:38

Okay yes, doesn't matter who.

tony.kay06:01:40

Same result

tony.kay06:01:00

what is the code for get-state?

cjmurphy06:01:05

`(defn get-state [] @(prim/app-state (-> app deref :reconciler)))`

cjmurphy06:01:26

Mine comes up with joe@ all ready to log in.

tony.kay06:01:40

saved chrome form state

cjmurphy06:01:37

Not a Fulcro form as such. :main is just a table in a union.

tony.kay06:01:30

So, you are claiming that you start a pristine template, load the page, log in, and see that state?

cjmurphy06:01:05

But joe is the defaulted user for me.

tony.kay06:01:07

up to date on develop branch?

tony.kay06:01:28

or master…they’re the same currently

tony.kay06:01:37

commit 8176673e509c80ca7376d3f7cdd7c4ecd7c56a23

cjmurphy06:01:43

Maybe not develop, have to check, but it is an up to date copy I believe.

tony.kay06:01:49

or commit 972a456e86e2bba65f1ebf48d34ebf06214032ce

tony.kay06:01:18

cleaned project and browser cache?

tony.kay06:01:30

Not sure what else to tell you…other than “works for me”

cjmurphy06:01:57

Mine is master and I can see I did a bizare typo:

cjmurphy06:01:00

{:keys [:current-user]}

cjmurphy06:01:09

I put the colon in there.

tony.kay06:01:13

shouldn’t matter

tony.kay06:01:41

did you change project versions of any deps?

cjmurphy06:01:58

Fulcro Inspect updated.

cjmurphy06:01:15

I don't know how to see the commit hash thing.

tony.kay06:01:48

@currentoor making sense of routers?

cjmurphy06:01:10

commit b39cc459fefd9b4e16063b98384fdecdbb89c9d8, one after yours.

tony.kay06:01:10

that was just a readme change

tony.kay06:01:20

I just updated all deps to current, and it works there too

tony.kay06:01:31

so, still no clue why yours looks incorrect

cjmurphy06:01:12

I just did everything fresh w/out the colon and logged in and state is now fine:

cjmurphy06:01:14

:main {:page {:id :main}}

cjmurphy06:01:43

I'll go back and put the colon, slow machine...

tony.kay06:01:44

the colon was on props?

tony.kay06:01:54

it won’t matter…unless I’m going mad

cjmurphy06:01:04

Yes - so not normal destructuring.

cjmurphy06:01:36

I'm sure in normal destructuring it would baulk at you?? Actually I have no idea.

tony.kay06:01:51

no, it is ok

tony.kay06:01:06

AH…found it

tony.kay06:01:13

RELOAD the page

tony.kay06:01:17

while logged in

tony.kay06:01:26

it’s a bug in the initial app state that the server builds

cjmurphy06:01:50

So reloading causes the bug.

tony.kay06:01:54

the server state runs the link queries, then normalizes the tree…but there is no user query so it ends up being there

tony.kay06:01:58

it is harmless

tony.kay06:01:05

and would be a pain to fix on the server

tony.kay06:01:38

An easier “fix” would be to use shared instead of link queries

cjmurphy06:01:13

The easiest fix is to avoid links altogether.

cjmurphy06:01:41

I don't see they are at all essential and cause lots of headaches.

tony.kay06:01:14

shared doesn’t update on localized refresh…link queries do

tony.kay06:01:56

actually, it might be relatively easy to fix on the server.

tony.kay06:01:42

Yeah, actually the fix isn’t hard at all

cjmurphy06:01:10

That's good, for clarity, no one likes denorm state in field joins.

tony.kay06:01:11

instead of sending a tree as initial state, send the normalized db…and install it as an atom instead of as a plain map

cjmurphy06:01:40

Sounds like a big kind of change.

tony.kay06:01:53

I already have the normalized db

cjmurphy06:01:59

But init state diff to queries.

tony.kay06:01:02

it is actually one line less code in one spot

cjmurphy06:01:23

Great find then.

cjmurphy06:01:39

Well queries are always denorm data that comes across.

cjmurphy06:01:50

But this is all local data.

cjmurphy06:01:07

remote queries

tony.kay06:01:21

yes, this is all data generated by the server…server makes normdb -> mutations -> tree -> render + initial state

tony.kay06:01:14

it currently sends the tree as initial state (because that is easier when writing the code to work either way)…but it could just as easily send the normdb instead

tony.kay06:01:38

oh wait…that is what it’s doing 😕

tony.kay06:01:41

oh, the normalized state is built from the UI initial state tree

cjmurphy06:01:23

I can see the refresh after logging in is causing the problem, regardless of the colon.

tony.kay06:01:33

yeah, it isn’t much code, but I’d have to step through it carefully to figure out where to change it.

tony.kay06:01:42

colons are allowed in destructuring

tony.kay06:01:23

feel free to fix the SSR if you want and send a PR…I’m not really worried about it to derail other things to fix it

cjmurphy06:01:45

Okay I'll have a look sometime soon if can 🙂.

martinklepsch11:01:34

Hey — I’m looking for the sources of the book but couldn’t easily find them in the repo… Anyone have a pointer for me? 🙂

martinklepsch11:01:41

Hm. I meant like the source text files (asciidoc I guess?) not the sources for the examples

martinklepsch11:01:26

yes! thanks, tomatoes on my eyes it seems 🙃

claudiu11:01:17

u're welcome 🙂

currentoor17:01:57

@martinklepsch I had trouble finding the source of the book too

currentoor17:01:18

Maybe that should be more discoverable?

wilkerlucio17:01:14

what about having a badge to "fork me on github" linking to the source?

currentoor17:01:33

that would be very discoverable

tony.kay18:01:33

@thosmos I was just running the template last night

tony.kay18:01:59

caching in browser?

thosmos18:01:30

maybe, i thought that was turned off ... checking ...

tony.kay18:01:16

remember that your URL is localhost with some port…so different apps that you play with that use the same URL can cause all sorts of fun

thosmos18:01:48

yep that was it, my bad

thosmos18:01:49

never assume

wilkerlucio18:01:00

@thosmos tip: use . domains to avoid cross local site caching, if you use anything . it will point to localhost, examples: ... this way you can keep site resources separated (local cache, cookies, url history...) even though they will be all in localhost effectively

thosmos18:01:26

@wilkerlucio oh wow, first time I've heard that! thanks!

wilkerlucio18:01:38

no problem, happy to help 🙂

tony.kay18:01:36

those are from Inspect, I think

thosmos18:01:35

is an intention with inspect that you will eventually be able to edit state values and have the UI update?

wilkerlucio18:01:08

not planned, but sounds like an interesting feature, you wanna open a issue?

tony.kay18:01:24

I would suggest that you have a REPL for that

tony.kay18:01:37

and that the more interesting case is to run transactions, not bit twiddle

wilkerlucio18:01:07

interesting, I had not though about enabling adhoc transactions, but seems cool, and easy to implement

tony.kay18:01:13

for example, slide db history back a few steps, edit code (hot code reload), re-interact

wilkerlucio18:01:14

I'm opening a issue for that 😛

tony.kay18:01:36

the “re-interact” could be either manual, or a forward play of the history of txes

wilkerlucio18:01:06

@tony.kay for what you are talking, I have a slightly bigger idea, that would be "process recording"

tony.kay18:01:14

yes, exactly

tony.kay18:01:24

record a sequence of transactions that can be replayed at any time

wilkerlucio18:01:29

after we have snapshots, that would be the next level, we record a initial db and interactions, and replay from that

wilkerlucio18:01:50

yup, we are finding many ways to say the same thing, hehe 🙂

wilkerlucio18:01:27

@thosmos about the error, I remember an error similar to that in past, are you using the latest inspect?

wilkerlucio18:01:40

beause I think that issue was fixed

wilkerlucio18:01:49

the latest is -alpha4

currentoor18:01:49

@wilkerlucio i’m on -alpha4 and i can confirm that i also see that error, despite everything appearing to work fine otherwise

wilkerlucio18:01:37

thanks, we might have to check again, I remember something like that was happening before because the process of init app state was triggering a mutation before the app was initialized, causing it to don't find the app

wilkerlucio18:01:02

but maybe this is something different

tony.kay18:01:09

looks like the app id is nil

wilkerlucio18:01:26

yeah, that was the problem before, app wasn't ready to take the transactions

wilkerlucio18:01:05

app id should never be nil, if user don't provie the inspect will generate one

macrobartfast21:01:29

I could find out by trying it (and am doing that now) but is there harm in starting the figwheel and main server at the same time in intellij?

macrobartfast21:01:48

or should I start one or the other and wait?

macrobartfast21:01:04

I know I should be able to deduce this from the excellent docs, but a bit uncertain about a good workflow for building a learning project that stores pets and their preferred foods in an actual datomic Starter database.

macrobartfast21:01:05

what I'm imagining as a possibility is that I run 'lein new fulcro favefoods', then build up the Pet, PetList, Food, and FoodList components via defsc and then their factories; add the Root element; add the ui-pet-list and ui-food-list to the Root; enable a server; figure out how to get the pets and their favorite foods to store in an in-memory Datomic database on a server; then move the in-memory database to, say, a PostgreSQL backed Datomic instance.

macrobartfast21:01:17

If I could click on a pet, see their favorite foods, be able to add a favorite food and have it stored in the database, as well as click on a food and edit it, I'd have a great start on being able to build apps with Fulcro.

macrobartfast21:01:28

does this sound reasonable? I'm totally unsure how devcards play into this scenario... do you start these things there and graduate them to something else, or do you morph the devcards into the final product, or something else?

cjmurphy22:01:09

@macrobartfast: All I can say is that from experience I know I'm gonna use devcards a lot more in the future. Perhaps first up your big application could be done just using initial state, client only. Your components would not even need to display what they have as at this stage you are just making sure that state is correct. Then put in buttons for your state changes. If you need a server at this stage just make one that serves static/example data. Then concentrate on one component at a time by having a devcard for it. Here your render method would start to have more than just buttons, and you would be concentrating on the css. Once you have a nice working demo application introduce the server and more realistic data.

macrobartfast22:01:25

ok, pondering all that... thanks!

currentoor23:01:25

is there a way to add a set of default entries to a table and still use the initial app state collocated protocol?

currentoor23:01:22

i have a :widget/by-id table and it has a number default widgets already built in, and now i’m porting the app over to use the collocated initial app state stuff

currentoor23:01:21

i suppose i could just assoc the default stuff in on a post initial load mutation? is that a bad approach?

cjmurphy23:01:22

I wonder if you could have a def of the default widgets' state and be taking from it inside the initial state methods themselves?