Fork me on GitHub
#fulcro
<
2018-03-09
>
levitanong06:03:46

@tony.kay Was looking through the response middleware docs: http://book.fulcrologic.com/#_response_middleware and found a curious line there talking about merging specific errors into state. Doesn’t this conflict with the principle of only giving what has been queried?

levitanong06:03:54

or would i have to modify the transaction? Yeah that’s probably what needs to be done

tony.kay06:03:01

@levitanong So, like I said, I'm not sure what I have in the docs is right. Loads have a specific story, and mutations another. So, the stuff about modifying the error stuff only works on mutations, but I think I indicated it was a general thing.

tony.kay06:03:34

@donmullen The logging is a relatively recent rewrite, so I would be interested in knowing about bugs.

levitanong07:03:06

ahhh i see. okay thanks @tony.kay

tony.kay16:03:52

@levitanong Looks like Fulcro Inspect is breaking it somehow

levitanong17:03:26

@tony.kay fascinating. You are talking about the repro repo?

tony.kay17:03:58

I’ve already isolated the bug to inspect

tony.kay17:03:02

I’m working on fixing it now

tony.kay17:03:15

good news: you’re not going crazy 🙂

tony.kay17:03:09

Fulcro Inspect 2.0.0 released to clojars

tony.kay17:03:16

@levitanong this fixes your issue

levitanong18:03:37

:D hurrraahhh!!!!

magra18:03:57

Hi, I am working to figure out how to pass a mutation to a function. When I "hardcode" it it works fine but when I try to pass it I get an error that the var is undefined. The following works fine: {:onClick #(prim/transact! this `[(api/update-something {:db/id ~id})]) Because writing inputs got very repetitive I wrote a function (editfields this editkeys fixedkeys mutation). It builds editable input-fields (for [editfield editfields]) fixedkeys are eg. :db/id which I need for the mutation and mutation should be where I pass api/update-something. Everytime I try to pass api/update-something I get an error that the var is undefined. When I quote or syntaxquote it the code will not work.

tony.kay18:03:22

so, save yourself some big headaches and put the computation logic in a let outside of the quoting

tony.kay18:03:37

into into for?

tony.kay18:03:42

OMG that’s hard to read/understand

tony.kay18:03:21

also, where are you even using mutation?

tony.kay18:03:32

sorry, clean that up a lot, and ask again 🙂

magra18:03:52

Both examples work, because api/update-office is there literaly. How do I replace the literal api/update-office with a mutation.

tony.kay18:03:11

the specific answer to that question: pass a symbol

tony.kay18:03:32

api/update-office is the value to pass as an arg,

tony.kay18:03:15

(defn do-thing [this m]
   (prim/transact! this `[~m]))

(do-thing this `api/update-office)

tony.kay18:03:29

or, if you want to pass the entire tx, just pass the tx…it is just data

tony.kay18:03:55

(defn do-thing [this m]
   (prim/transact! this m))

(do-thing this `[(update....)])

tony.kay18:03:21

unquotes happen when quote happens, so don’t expect some weird deferred eval of unquote

wilkerlucio18:03:03

@magra you are pulling data directly from dom nodes, that's a very bad thing to do here

wilkerlucio18:03:42

you should be updating some state instead, and then just using it on your mutation, your form should have the data on the DB, this way you can just build up your data as user is typing, then you have map all ready to use on the mutation

magra19:03:34

@wilkerlucio thank you, yes. I am aiming to go that way.

magra19:03:45

aahh two ~s!

magra19:03:51

Thanx!!!!!!

magra19:03:32

`[(~mutation ~mutmap)] 
works.

magra19:03:12

And thank you for your patience!

tony.kay19:03:29

I’ve just release a new lein template for fulco with the following changes: 1. lein new fulcro app now defaults to shadow-cljs. It’s faster, works better with the js ecosystem, and is just nicer to work with IMO. You can get a figwheel-based project with the lein new fulcro app figwheel option now. 2. Updated dependencies, including to the new inspect The uberjar size is also reduced by about 7MB in this new template due to refined deps. Let me know if anyone has issues, and thanks to @thheller for making such a great tool (shadow-cljs). I also dropped support for v1 apps.

thheller22:03:25

wow. nice. 🙂

levitanong19:03:42

@tony.kay on a blank template, running the test build (on port 8022) will give this error: [fulcro.client.impl.application] Mutation fulcro-spec.selectors/set-active-selectors failed with exception Error: Vector's key for assoc must be a number.

tony.kay19:03:52

that’s a minor bug on fulcro-spec I have not figured out. Should not hurt anything….does it?

levitanong19:03:28

i’m not entirely sure. 😅 this is the first time i’ve looked into testing.

tony.kay19:03:43

I haven’t fixed it because it doesn’t seem to hurt anything

tony.kay19:03:47

just annoying

tony.kay19:03:53

so, spending my time elsewhere

levitanong19:03:51

okidoki! currently trying to figure out why my app test thingy doesn’t seem to work. Considering setting up a new template and just transferring code to see if that makes it work. Will let you know if I find something noteworthy.

tony.kay19:03:20

I just ran it out of the latest, and it works, but does give that consol error

souenzzo20:03:09

(defquery-root :cart/total-price
  (value [{::keys [entity]} _]
     (let [items (:cart/items entity)
           prices (map :item/price items)]
       (reduce + prices))))

(defquery-root :cart/total-price-with-carrier
  (value [{::keys [entity]} _]
                 ;; ??? \/ it will be here?
     (let [total-price (:cart/total-price entity)]
       (+ total-price 15))))
there is how to do this? if not, how to handle this? (calculate an attribute based on another calculated)

tony.kay23:03:48

@souenzzo So, I assume you’re putting the entity into the env in some way. If so, then yes, you could do it that way. Personally, I’d define a much more graph-like data structure on the client that included such computed data, and combine it together with a single query.

tony.kay23:03:37

I’d define a Cart with CartItems, and the Cart would query for things like :cart/carrier-fee. Then I’d have a defquery-root for the :current-cart that used (load this :current-cart Cart) on the client to pull in the entire current cart (as a graph result).

tony.kay23:03:58

that way if there are multiple tabs going you get up-to-date complete info