Fork me on GitHub
#fulcro
<
2018-03-28
>
eoliphant01:03:02

Hi, I have a quick question. I’m integrating an authentication lib (auth0) with my fulcro app. Their recommended approach is a ‘google style’ nav over to their portal to authenticate, then a redirect back to your app with the oauth token, etc. I started off trying to make a /callback route ( I’m using the fulcro/bidi/pushy appraoch from fulcro template), but that of course requires a catch all route on the server, i’m not clear on how to configure the server for that. and with that, or just redirecting to my root, I need to grab and process those query params and haven’t quite figured that out either.

tony.kay03:03:34

the fulcro-template project shows this. it has SSR, re=routing after login, and serving the same html file for all “routes”

tony.kay03:03:21

in the “easy” server, you can use a post-hook in the server to hack in a handler that can just server the index file based on pattern matching (e.g. ends in html). The post hook is jst before the not-found handler. See the Developer’s Guide for hooks. If you hand-built the server, then just put it in your Ring stack.

bbss07:03:47

Hmm, the :value field on my dom/select seems to be ignored. onChange works though. Maybe this has to do with the component not having an ident? I also can only get to the local state in the render through prim/get-state, not through the destructuring in the third arg in arglist of defsc.

wilkerlucio12:03:30

@bbss the third argument is not state, it's computed props, did you tried logging the value you are putting on :value? it's preferable if you have thi on the actual app state, the react state is better ignored most of the time (in my experience the only time I think its a good case for react local state is if you are using data for animation transitions)

wilkerlucio12:03:54

and about the ident, its a good practice to have idents on every component you have that change data, you can do without it, but is much harder and you lose the ability to use more generic mutations like m/set-value!

eoliphant12:03:09

Thanks @tony.kay, yeah I’m using the easy server so will explore the hooks

bbss13:03:07

@wilkerlucio Ah, I was mistaken about the third arg, thanks. I thought I was pulling some stuff from there in a different component but no 😅 . Yes, I tried logging, putting a default value that's def in the list of options. Just seems to be ignored. It's not a blocking issue form e and I guess I could get around it by using props properly in stead of local state. I don't use local state too much I think, just for quick hacks and ui editting concerns. And for drawing a selection box on top of the canvas of my starcraft II screen 😄

tony.kay15:03:56

2.4.4 Released to clojars with alpha DOM fixes. @mitchelkuijpers

🎉 16
donmullen16:03:11

I have a devexpress/dx-react-grid that I am using in a fulcro app for displaying data (read-only). I’d like to be able to update the child dx-react-grid from the parent (stuff like changing hidden columns or setting various search/filter fields in the grid). My defsc FulcroGrid wraps the component and currently has query/idents:

:query         [:grid/id :grid/columns :grid/rows :grid/hiddens]
:ident         [:grid/by-id :grid/id]
I successfully wrote a mutation to update the :grid/hiddens in the app-state — but the grid component does not update. I tried a follow-on read in transact! for the parent prop that holds the dx-react-grid wrapper - but that didn’t work. What is the proper way to get the underlying react-grid to re-render?

tony.kay16:03:24

@donmullen this may sound silly, but React is React…passing a component updated props should update it. Fulcro doesn’t interfere with that. So, if the props are changing in the parent, and you’re passing them through, then the problem is with that component, not Fulcro.

tony.kay16:03:47

possibly you misspelled something?

donmullen16:03:09

@tony.kay May be the component - certainly could be user error on my part! I have code that will completely switch out to a new set of grid props - and that works. Perhaps the react component is ignoring certain props used for initialization settings in ‘controlled’ mode. Will continue to investigate.

wilkerlucio16:03:53

@tony.kay are you releasing a new 2.5.x with the fixes too?

tony.kay16:03:33

haven’t ported them up yet

wilkerlucio16:03:33

no a problem, just wondering to choose which version I should keep the codebase here into

tony.kay16:03:56

2.5 might should be 3.0. The i18n promotion will require some additional code for anyone that uses it.

tony.kay16:03:53

The DOM promotion is drop-in

wilkerlucio16:03:05

cool, so 2.4.4 it is

tony.kay16:03:49

for now. I may back-port anything I’ve done in 2.5, and defer it for now without alpha promotions.

tony.kay16:03:38

oh….I remember what the other thing is in 2.5: reduced deps. I’ve changed all the server stuff to dynamically resolve things, which makes it possible to write your own server without even needing Ring

myguidingstar16:03:29

hi every one, I'm happy to announce walkable 1.0.0-beta1 is now on clojars

👏 24
👍 8
myguidingstar16:03:49

more importantly, lots of documentation have been written

eoliphant20:03:33

@tony.kay, hey I’ve been trying to get the hook working per your note to just serve my index page for all requests. couple questions, you mentioned a post hook, but I only see the api, etc for pre and fallback hooks. So the fallback hook is just before the not-found handler in the chain. I tried that, but it doesn’t seem to get invoked

(defn do-nothing
  "docstring"
  [req]
  (println "req: " req)
  req)

(defrecord HTMLServer [handler]
  c/Lifecycle
  (start [this]
    (let [old-fallback-hook (fulcro.easy-server/get-fallback-hook handler)
          new-hook (fn [ring-handler]
                     (fn [req] (println "req: " req) ((old-fallback-hook ring-handler)  (do-nothing req))))]
      (fulcro.easy-server/set-fallback-hook! handler new-hook)))
  (stop [this] this))

(defn build-server
  [{:keys [config] :or {config "config/dev.edn"}}]
  (make-fulcro-server
    :parser-injections #{:config}
    :config-path config
    :components {:html-server (c/using (map->HTMLServer {}) [:handler])}))

tony.kay20:03:02

It should get hit on missing pages…I thing your function isn’t quite right, but it should still get hit

tony.kay20:03:28

whatever matches the guide and fulcro-template should work.

tony.kay20:03:43

ah right, the template uses SSR, so it isn’t a great example 😞

tony.kay20:03:13

yeah, try pre-hook…something else is probably just serving the thing you’re looking for

eoliphant22:03:18

ok actually duh, i handn’t tried a missing page yet lol, let me try that first, then will try the pre-hook.

eoliphant22:03:18

yeah that actually did it 😉 lol. So, I’m gonna just have my func call easy server/index or whatever if it matches.