Fork me on GitHub
#fulcro
<
2018-03-16
>
tony.kay01:03:16

@splayemu So, your server-side mutation has to return a mapping from temp to real, right?

tony.kay01:03:14

otherwise, you may have uncovered a bug. The resolution in queues and app state has to do with not being able to predict when an additional operation might be triggered by the user, meaning the thread has been released between operations on the client side, which forces the two mutations to go on separate network requests. If you're submitting them right together without letting go, then the internals of Fulcro might be combining them into a single network transaction...which would cause this problem. If that is the case, then I would consider that a subtle bug...the internals should probably not join together two unrelated calls of transact in one network request if they contain temporary IDs.

Spencer Apple18:03:00

I did return the mapping. Fulcro inspect seemed to think the transaction returned fine. I can verify by adding come client state and seeing if that get's autoresolved while the tempids in the next mutation do not.

cjmurphy17:03:01

I don't like to use the keystroke ctrl-f with Fulcro Inspect, as it interferes with find in my browser, so instead do this: :external-config {:fulcro.inspect/config {:launch-keystroke "ctrl-v"}}. Works fine from a project.clj file. Does not seem to be recognised when put in a shadow-cljs.edn file. Guess I should report on the shadow-cljs slack group...

etemtezcan18:03:09

hello. I am triying to compile and make changes to fulcro-routing video. I cloned to project, opened with intellij and cursive. from an external cmd line , ı run command "npx shadow-cljs watch main cards test". http://localhost:8022/cards.html is working, ı can see routing.intro. How can I see changes I made in files automatically?

tony.kay20:03:49

@U1W0UBLLB Editing and saving should hot reload the code.

wilkerlucio18:03:28

@cjmurphy as a work around, you can install the inspect by calling the init function yourself, so you can send the configuration as you please

cjmurphy18:03:30

@wilkerlucio: Funnily enough the same thing (except tool ns rather than core) in the tool I wrote, because of course I copied yours 😜 Still workarounds are workarounds...

wilkerlucio18:03:44

@cjmurphy heheh, yeah, we have to know if shadow uses a different way for reading external config, I remember copying this impl from some other project, maybe we should have a lib for reading external configs :man-shrugging:

thheller19:03:49

@cjmurphy did you specify :compiler-options {:external-config ...} in your build config? it won't get picked up outside :compiler-options

cjmurphy19:03:49

No, just did it the way it is done in lein: :external-config being a sibling key with :preloads.

cjmurphy19:03:02

This is modifying the shadow-cljs.edn file in the websockets2-demo

cjmurphy19:03:33

By the way I notice that devtools is installed after the other tools. That means that both default-db-format and fulcro.inspect don't have nice messages saying they are installed.

wilkerlucio19:03:36

I always put the devtools first, for this same reason

cjmurphy19:03:44

But devtools done automatically for you with shadow, so you shouldn't be specifying it at all, that my understanding.

cjmurphy19:03:44

; shadow-cljs already enables console print and plugs in devtools if they are on the classpath,

cjmurphy19:03:52

That quote comes from wsfix.development-preload.cljs in the websockets2-demo.

thheller20:03:38

devtools.preload is always injected first when its on the classpath

thheller20:03:57

oh doh. its actually not injected at all if other :preloads are specified

thheller20:03:28

will fix that

thheller20:03:29

scratch that .. everything is fine 😛

cjmurphy20:03:25

"`devtools.preload` is always injected first when its on the classpath" - yes that's consistent with what I see. The thing is, are there any tools that should come before devtools? If not then devtools should come first. Of course that's a question without an answer...

thheller20:03:26

you can always add it manually if you need to control when it gets loaded

thheller20:03:57

otherwise since its just affecting the console it should be safe to use first?

thheller20:03:48

@cjmurphy :external-config did not invalidate the cache so if you had a cached build it didn't pick up your config change. fixed that in 2.2.12

mitchelkuijpers21:03:15

Tried out the new DOM stuff, really loving it! Especially with the localized CSS

wilkerlucio21:03:54

@thheller @cjmurphy I think unless the user specifies a position for devtools on the :preloads, it should come first

wilkerlucio21:03:57

because it's likely that other tools will want to print things on the console during setup/installation, and if they come before devtools it just looks bad

mss22:03:50

having an issue formulating a query, and potentially looking for a little help simplifying the query. let’s say I have a query with something like:

'[[:recipe-page/active-recipe _] [:db/id
                                  :recipe/name
                                  {:recipe/steps {:prep-steps/by-id [:db/id :prep-step/name :prep-step/some-prop]
                                                  :plating-steps/by-id [:db/id :plating-step/name :plating-step/some-other-prop]}}]]
where my normalized app state looks something like:
{:recipe-page/active-recipe [:recipes/by-id 2]
 :recipes/by-id {2 {:db/id 2
                    :recipe/name "My second recipe"
                    :recipe/steps [[:prep-steps/by-id 5]
                                   [:prep-steps/by-id 6]
                                   [:plating-steps/by-id 7]]}}
 :prep-steps/by-id {5 {:db/id 5 :prep-step/name "Chop the thing" ...}
                    6 {:db/id 6 :prep-step/name "Slice the other thing" ...}}
 :plating-steps/by-id {7 {:db/id 7 :prep-step/name "Plate the thing" ...}}}
for whatever reason, the actual attributes of the recipe/steps join aren’t getting pulled in, and all that’s getting resolved is an ident pointing to either a plating-step or a prep-step, i.e. recipe-steps looks like:
[[:prep-steps/by-id 5]
[:prep-steps/by-id 6]
[:plating-steps/by-id 7]]
as opposed to something like:
[{:db/id 5 :prep-step/name "Chop the thing" ...}
 {:db/id 6 :prep-step/name "Slice the other thing" ...}
 {:db/id 7 :prep-step/name "Plate the thing" ...}]
am I doing something wrong here? should I not be doing an ident lookup that deep into a query?

wilkerlucio22:03:38

@mss your output doesn't match your query

wilkerlucio22:03:12

in your query, you have :prep-steps and plating-steps in separated keys at :recipe/steps, but on your normalized data you have a single vector

mss22:03:16

is that not how unions work? two different “paths” so to speak?

wilkerlucio22:03:12

oh, sorry, I read it wrong (the query), let me re-evaluate

mss22:03:58

sorry that it’s a little complicated. was trying to make a relatively simple example that’s close to the issue I’m working through

wilkerlucio22:03:48

it looks correct, so you are saying that your :recipe/steps are retuning the idents instead of the actual data?

mss22:03:10

can’t quite figure out why

wilkerlucio22:03:23

can you paste the source for the relevant components please (just queries and idents)

mss22:03:26

looks roughly like this:

(defsc PrepStep [this props]
  {:query [:db/id :prep-step/name :prep-step/some-prop]
   :ident [:prep-steps/by-id :db/id]})

(defsc PlatingStep [this props]
  {:query [:db/id :plating-step/name :plating-step/some-other-prop]
   :ident [:plating-steps/by-id :db/id]})

(defsc RecipeStep [this props]
  {:query (fn []
            {:prep-steps/by-id (prim/get-query PrepStep)
             :plating-steps/by-id     (prim/get-query PlatingStep)})
   :ident (fn []
            (cond
              (and (contains? props :prep-step/some-prop)
                   (not= (:prep-step/some-prop props) ::prim/not-found))
              [:prep-steps/by-id (:db/id props)]
              (and (contains? props :plating-step/some-other-prop)
                   (not= (:plating-step/some-other-prop props) ::prim/not-found))
              [:plating-steps/by-id (:db/id props)]))})

wilkerlucio22:03:18

@mss this looks all correct, one thing though, the first snippet you posted here '[[:recipe-page/acti..., you copied from your code or typed? I noticed it's missing the {} for the join (the main one, from ident to query)

mss22:03:32

wow that was the issue 😭

mss22:03:16

so sorry to drag you through all that just to sanity check my queries

wilkerlucio22:03:29

no worries, I can only see because I got bitten by it so much already XD

wilkerlucio22:03:44

and are you doing some cooking app for yourself?

mss22:03:53

really appreciate the help

mss22:03:18

just toying around with fulcro to get a sense of how it works, want to ship something in the future but just trying to get a solid mental model of it at this point

mss22:03:28

I do love to cook though 😜

wilkerlucio22:03:18

nice, I think making an app is one of the best ways to learn, have fun 🙂

mss22:03:55

thanks again