Fork me on GitHub
#fulcro
<
2018-02-06
>
wei09:02:00

just started on fulcro and wanted to say thanks for the amazing documentation! probably the best I've seen in a clojure project

chrisblom10:02:26

i'm trying to understand routing: I have several pages, which are selected by the router. Each page provides a different view of the db, and I had these working individually in devcards

chrisblom10:02:12

But now that I placed a router in front of the pages, all state is prefixes with the page ident in the db

chrisblom10:02:01

So before i had something like :campaign-list/elems [...], and after adding the router i get

{:page-A {:pane {:campaign-list/elems [...]}}}, 
:page-B {:pane {:campaign-list/elems [...]}}}

chrisblom10:02:04

How do i get the separate pages to access the same :campaign-list/elems?

maridonkers10:02:01

@chrisblom Add a level of indirection? So make the pages refer to e.g. campaign list 1 and put the actual elements in there?

chrisblom10:02:34

thanks, i'll try that

claudiu10:02:14

@chrisblom Case u missed it, there's also a nice youtube video on fulcro routing ? https://www.youtube.com/watch?v=HJBI24yAdBQ

chrisblom11:02:51

@maridonkers, thanks, adding a level of indirection worked

pithyless12:02:47

I may have missed this in the docs (sorry), but why does fulcro use glog for client logging and timbre for server logging? Why not just use timbre everywhere?

mitchelkuijpers12:02:00

I wish it would remove Timbre.. Timbre on the server is a real pita

mitchelkuijpers12:02:17

But I think you can override the logger on the client

pithyless12:02:13

working off of the shadow-cljs template, I’m seeing a warning like this:

[:main] Compiling ...
Failed reading cache for fulcro.inspect.ui.events: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array

thheller12:02:05

should go away on the next compile if the cache write suceeds

thheller12:02:18

if it still fails please send me the target/shadow-cljs/builds/your-build/dev/ana/fulcro/inspect/ui/events.cljs.cache.transit.json file

thheller12:02:14

don't know why it would get corrupted though

pithyless12:02:03

I’m experimenting into backfilling fulcro and shadow-cljs into an existing repo that bootstraps with boot-clj and mount, so… there may be weirdness and kind of hard to make small reproduce case. I’ll slowly chip away at it, and let you know if I can figure out what’s going on ;]

thheller12:02:17

that should just work. the cache error is not critical as the compile will just continue without it, ie. recompile the file without cache.

thheller12:02:53

the problem with boot however is that it does weird things to the classpath which may completely destroy all cacheability

chrisblom15:02:10

I have another question. I have setup routing for pages and tabs within a page. I want to have different tabs on the User page

chrisblom15:02:12

so for example '/user/123123/details' and '/user/123123/history', should show the Details or History tab on the User page

chrisblom15:02:51

these have idents [:user-history/by-id :db/id] and [:user-detail/by-id :db/id] and I have routes in my routing tree to set the tab router to :user-detail/by-id and :user-history/by-id

chrisblom15:02:11

Similar to how it is done in the router tutorial video

chrisblom15:02:04

However, now the db has :user-history/by-id and :user-detail/by-id , but i want the Details and History tabs to just show different parts of :user/by-id

chrisblom15:02:18

How to i get these tabs to get their info from :user/by-id?

chrisblom15:02:56

So what i'm really asking is, how to I get 2 different components to render a different view of the same db entry?

tony.kay15:02:29

@chrisblom two views of the same entity = same ident

tony.kay15:02:37

that’s the whole point of normalization

tony.kay15:02:29

namespaced keywords mean you aggregate data. A “user” isn’t a class…it’s a bag of facts that happen to be arranged to “make sense” as a user

tony.kay16:02:11

it’s a user, that happens to have details, history, and other future stuff you have not even imagined

tony.kay16:02:05

Search for “We want to be able to merge data from different sources, we don’t want the schemas to dominate the semantics, right?” if you haven’t seen this talk.

chrisblom16:02:15

ok, maybe i'm missing something related to routing & idents

chrisblom16:02:35

how would i route to different components if these have the same ident?

chrisblom16:02:37

so say UserHistory and UserDetail both have ident [:user/by-id :db/id], how would the routing tree look like?

myguidingstar16:02:58

@chrisblom they have the same ident but have different queries

chrisblom16:02:11

can i route based on queries?

chrisblom16:02:44

i'm also no sure they have different queries, why can they not be the same?

chrisblom16:02:15

so with the same idents, the routing tree will look like this:

(r/make-route :user-history [(r/router-instruction :page-router [:user :page])
                                (r/router-instruction :user-tab-router [:user/by-id :param/id])])
   (r/make-route :user-detail [(r/router-instruction :page-router [:user :page])
                               (r/router-instruction :user-tab-router [:user/by-id :param/id])])

myguidingstar16:02:42

sure, they may or may not share the same query

chrisblom16:02:36

but if I understand correctly, routing is done on the first elem of the ident, so if the idents are the same, how will routing work?

chrisblom16:02:31

My router now looks like this:

(defrouter UserRouter :user-tab-router
  (ident [this props] [:user/by-id (:param/id props)])
  :user-history/by-id UserHistory
  :user-detail/by-id UserDetail)

myguidingstar16:02:05

I think if you have two different components then you're fine

myguidingstar16:02:11

even when they share idents or not

wilkerlucio18:02:26

@drewverlee by the code it seems your component doesn't have any query, it has too, on the video the query is empty?

Drew Verlee18:02:21

i’ll have to check later thanks for the hints

wilkerlucio18:02:32

I guess the code is missing the :query part, also the :ident, if you can't find on the video just ping us back, easy fix, but if that's the case we should warn Tony so he can add some annotations on the video or something

myguidingstar18:02:00

@tony.kay @wilkerlucio fyi, Hi all, I've been working on a new library called "walkable" It's something similar to fulcro-sql but a bit more flexible It leverages path·om's power

myguidingstar18:02:21

I need to write a proper Readme before pushing to github

wilkerlucio18:02:41

@myguidingstar looks pretty cool, I like the use of parameters you did, had you though about how to handle security? (to avoid exposing other users data or query abuse)

myguidingstar18:02:23

yes, you can write custom extra condition as functions (in stead of pure data structure like in given examples)

myguidingstar18:02:45

the signature of such function is: env → condition

myguidingstar18:02:31

you can plug session information (eg user id) into env and let the function decide

myguidingstar18:02:48

by env I mean pathom env

myguidingstar19:02:50

other kinds of guard can be achieved by some custom plain pathom plugins

wilkerlucio19:02:43

sure, nice on the initiative, let me know if you need any help to figure pathom stuff 🙂

myguidingstar19:02:32

atm I just need to focus on documentation

myguidingstar19:02:02

but I haven't read the newly arrived Connect part of pathom

myguidingstar19:02:35

not sure if I can leverage it for walkable

wilkerlucio19:02:15

a mix of things is possible, in the end connect is just some extra readers, at some point it might be interesting to generate auto-complete information from the sql schema, but I think this can be added later

wilkerlucio19:02:40

not sure if you saw, pathom now has an in progress book (just working on it now :)) https://wilkerlucio.github.io/pathom-book/DevelopersGuide.html

myguidingstar19:02:50

I saw you posted the doc here the other day, but haven't spent enough time on it

myguidingstar19:02:17

btw, I saw some sql being used in daveconservatoire project nodejs server

myguidingstar19:02:58

I don't know if walkable is able to take place there

myguidingstar19:02:35

omg, I should rename the source to cljc, they're all pure Clojure

wilkerlucio19:02:51

yeah, it has an internal library to handle that, but the async part needs some work, right now the way it process is too agressive

wilkerlucio19:02:11

can work for some range of cases, but I have feeling can bring problems at scale

myguidingstar19:02:07

you mean async part of what?

wilkerlucio19:02:32

of pathom, since daveconservatoire runs on nodejs, most of the things have to be async

wilkerlucio19:02:52

pathom has an async plugin that handles core async channels as attribute returns

myguidingstar19:02:31

wow, I haven't made use of that

wilkerlucio19:02:54

but currently it just goes processing everything as fast as it can (and may generate too many parallel processes at once, there is nothing holding it up)

wilkerlucio19:02:08

it's more useful for client side things, on clojure side it's just headaches XD

wilkerlucio19:02:09

but it's on the plan to make a decent async processor, the idea is to throw the attributes to be fetched on a controlled queue

wilkerlucio19:02:36

this way we can have very efficient async readers, to use both on cljs and to make parallel processing for the clojure side

wilkerlucio19:02:05

just not the priority yet, the sync one works well and it's been fast enough, the current focus is on the documentation for what is there already, and document/improve the GraphQL extensions

tony.kay21:02:53

@pithyless @mitchelkuijpers On logging: I’m planning on removing all external deps on logging, and defaulting the internal stuff to something you can easily override (like println). Choose your own logger. It should be in the next release.

pithyless21:02:14

@tony.kay Nice to hear about a more easily overridable logging mechanism for internal stuff. Honestly, I was just curious why there was a split between client/server; since you already were using timbre, why not use it everywhere? I figured that maybe you hit some issues with timbre on the client-side and switched over to glog. Otherwise, why do it at all?

wilkerlucio22:02:39

@tony.kay about queries, reading @myguidingstar example code I saw this [{(:field {:param "foo"}) [:a :b]}], while I've been doing this all the time: [({:field [:a :b]} {:param "foo"})]

wilkerlucio22:02:55

from what you remember, the first one was always valid, or works by accident?

wilkerlucio22:02:26

to be clear:

[{(:field {:param "foo"}) [:a :b]}] ; vs
[({:field [:a :b]} {:param "foo"})]

tony.kay22:02:10

@pithyless when Untangled was first written timbre was clj only

tony.kay22:02:45

and Om Next used the google logger, so it seems natural. Now that I’ve merged the projects, there is no need to split

tony.kay22:02:57

and I always love the opportunity to pare down the dependency list

tony.kay22:02:41

@wilkerlucio good one. David Nolen wrote the ast parser…you’d have to ask him. I’ve always done the parens as outer, and my opinion is that the other works by accident.

tony.kay22:02:02

I’ve never seen an example or document that uses the parens on the inner prop of a join

wilkerlucio22:02:44

I actually like the one inside much better, the outside one makes hard to associate the param with the requested key

wilkerlucio22:02:52

inside its cristal clear IMO

tony.kay22:02:44

good point. I tend to agree…read the AST expressions and see if it looks like an accident…might be worth changing the docs to suggest that way

wilkerlucio22:02:04

but I noticed the internal one doesnt work with the fulcro client parser... Im going to debug that in a bit

tony.kay22:02:30

it’s the same parser

wilkerlucio22:02:32

it doesnt find the key when we write the query that way, dont know why yet

tony.kay22:02:46

OH…`db->tree`

tony.kay23:02:40

the client “parser” is just db->tree, and it can’t deal with parameters.

tony.kay23:02:18

what’s the use-case for the client to work with the parameter expression?

wilkerlucio23:02:57

Im doing groceries, I’ll be back in 10, so I can type better :)

wilkerlucio23:02:58

well, nothing in special, I'm writing some demos for the fulcro graphql network

wilkerlucio23:02:16

and was convenient to just place the query with the params there

wilkerlucio23:02:24

it works fine using the outside version, but not the internal

tony.kay23:02:34

ah…yeah, db->tree is clearly expecting the format that the AST intends

tony.kay23:02:51

so I think we’re back to “it works by accident”

wilkerlucio23:02:52

but that's weird, it should rely on the AST

tony.kay23:02:17

no, it can’t rely on just the AST…it’s a recursive data walk using the query as a guide

tony.kay23:02:33

it could possibly be re-written to use the AST, but it currently is not

wilkerlucio23:02:45

why not the AST as a guide, using the query doesn't introduce complexity to deal with the variations?

wilkerlucio23:02:12

ok, I'll see how hard it is to make it compatible

tony.kay23:02:28

it is true that it should probably have been written to convert the query to an AST first, then do the algorithm…

tony.kay23:02:11

db->tree is also our biggest performance overhead on the client…so rewriting it would be nice if we could make any gains there. We have a reference implementation 🙂

wilkerlucio23:02:07

sure, I wonder if the pathom implementation is faster than the current, probably not, but it's way simpler to understand

tony.kay23:02:28

I was thinking something similar 🙂

tony.kay23:02:56

I think possibly transitive data structures could be used…

wilkerlucio23:02:46

yeah, it's not hard, just have to use the correct functions, into for example use transitive structures

wilkerlucio23:02:12

by the way, I think develop is broken

wilkerlucio23:02:22

I tried to start a REPL and it complained about not finding some log deps

tony.kay23:02:32

yes, I’m refactoring logging…

tony.kay23:02:35

you might try cleaning

tony.kay23:02:47

tests all ran

wilkerlucio23:02:09

humm, ok, let me try

tony.kay23:02:13

at least I thought they did 😉

wilkerlucio23:02:24

had you tried stopping the REPL and launching a new one?

tony.kay23:02:00

that should fix it

tony.kay23:02:15

nope, one more

wilkerlucio23:02:20

no problem 🙂

wilkerlucio23:02:52

@tony.kay can't find tests for db->tree, do they exist?