Fork me on GitHub
#fulcro
<
2018-04-03
>
bbss10:04:06

Are set-query! calls handled asynchronously? The get-query of my component doesn't change after using set-query! But it does seem to pull in the changed query data after a push. Strangely enough it doesn't do that a second time though.

tony.kay15:04:28

@bbssNot async, no. It is not heavily used, and was radically changed at 2.0…so expect that you could possibly find a bug. The refresh rules are identical with transact (in fact, it is a transact internally)

tony.kay15:04:58

in other words, refresh happens on the subtree where the set-query! runs. You’ll need to add :follow-on-reads to the options if you want to refresh other parts of the UI tree.

tony.kay15:04:26

Also, in case you’re analyzing the output of get-query in a REPL: get-query is now technically a function of app state. When you call it in a UI component there is a dynamically bound var to app state that get-query can pull from. You’ll notice that it accepts a second parameter (get-query C state)…this is the version you’d need to use from a REPL to see the updated query. There are a decent number of tests around the dynamic query algorithms, and if they’re working for you “a second time”, then you really just need to make sure the refresh rules are being met as normal.

eoliphant16:04:50

hi are there any examples around of setting up client request middleware ? I need to tack a JWT token onto my requests. I’m assuming this is the best way to do it?

tony.kay16:04:06

Developer’s guide

tony.kay16:04:45

It basically looks like ring

eoliphant16:04:18

ok yeah I saw the fuller example for the file upload in the book

eoliphant16:04:51

ok, think i got it, just call the default-one-from mine, and add my stuff

tony.kay16:04:31

I’ve updated the Developer’s Guide to not include the bootstrap chapter (which is now just a top-level doc in Fulcro repo for now). This makes it load much faster.

eoliphant17:04:18

Hey I did this, seems to be working,but just wanted to make sure there’s nothing obviously amiss

(defn token-wrap-request
  "just passthrough for now"
  ([] (token-wrap-request identity))
  ([handler]
  (let [new-handler (net/wrap-fulcro-request handler)]
    (fn [req]
      (println "passing through" )
      (new-handler req)))))

tony.kay17:04:16

well, normally you’d compose them externally

tony.kay18:04:37

in other words you would not mention wrap-fulcro-request

eoliphant18:04:42

ah see, lol, that’s why I asked, haven’t really done much with ring so you mean like threading the handler through them?

tony.kay18:04:52

you’d do your wrapping assuming that handler included that at some point

tony.kay18:04:31

(-> (wrap-fulcro-request) (token-wrap-request))

tony.kay18:04:50

whatever order makes sense for what you’re doing

eoliphant18:04:44

ok but, ugh what I’m not clear on is where that ‘goes’. Do I create a third (or anonymous) function that contains that thread, and that’s what I specify as the :request-middleware?

tony.kay18:04:11

the result of that threading is your middleware

tony.kay18:04:50

each step returns a new (fn [req] req')

tony.kay18:04:03

that that is what the middleware is: a function to morph the request

eoliphant18:04:51

ok, yeah I think I got it