This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-12
Channels
- # adventofcode (6)
- # beginners (148)
- # boot (5)
- # calva (1)
- # cider (10)
- # cljdoc (10)
- # cljs-dev (8)
- # cljsrn (10)
- # clojure (180)
- # clojure-dev (24)
- # clojure-europe (2)
- # clojure-finland (1)
- # clojure-italy (32)
- # clojure-losangeles (1)
- # clojure-nl (40)
- # clojure-spec (10)
- # clojure-uk (44)
- # clojured (4)
- # clojurescript (88)
- # community-development (33)
- # core-async (7)
- # cursive (19)
- # datomic (98)
- # duct (3)
- # events (1)
- # figwheel-main (10)
- # fulcro (62)
- # leiningen (23)
- # luminus (18)
- # off-topic (19)
- # pedestal (6)
- # re-frame (46)
- # reagent (21)
- # ring (17)
- # ring-swagger (3)
- # shadow-cljs (94)
- # slack-help (9)
- # spacemacs (14)
- # sql (1)
- # testing (4)
- # tools-deps (14)
hey @tony.kay, quick question. a follow on to my last, i have access to the reconciler in my resolver now, but I’m not clear on how to issue an arbitrary query. so that I can do something like (let [token (??? resolver [[:sec-token '_]])]
?
@eoliphant get the state atom and do a get
on that?
You can also issue queries using db->tree
(https://github.com/fulcrologic/fulcro/blob/bae67e67abe1b15c74a10768be53c3d83fcdc411/src/main/fulcro/client/primitives.cljc#L1335) but getting the app state and working with it directly seems better for your use-case
are you running Pathom on the client by the way @eoliphant?
it’s quite neat that you can wrap them in pathom resolvers and then have a nice interface for Fulcro to work with
also note that you can also pass an atom to :initial-state
when building the Fulcro client
so (I think) what you could have done is set up a state atom, pass it to initial state
By the way I am very much a beginner with Fulcro as well so don’t take anything I say as gospel 😛
i’m actually 50/50 about the suitability of keeping that token in the app db at all
since the security lib, we’re using already maintains it in local storage or something
hey quick question Im seeing that (:state reconciler)
gives me just the app db, and (prim/app-state reconciler)
seems to return it plus a bunch of other stuff
yeah, that’s why I’m back and forth about it, probably needless complexity. Since the js lib, that handles this is already managing that
https://github.com/fulcrologic/fulcro/blob/develop/src/main/fulcro/client/primitives.cljc#L2438
there’s other info, about the user that might be useful to stick in there, but the token itself, probably not so much so
in my application I am storing the security token in an https-only cookie. So I don’t have to care about it at all; it’s passed automatically with requests (and stored)
but for you that’s obviously not an option since you are working with an existing API
if there are no other factors at play I would just leave it in local storage and not pull it in the app db
since we basically want to: add the token, try the request, if it 401's refresh the token, then retry etc. each time so looking into that as well, and as we talk about it more definitely going to just rip it out at this point lol
lol yeah. Well on my application I use the built-in http fulcro remote (since my API is fulcro-compatible). I added a middleware which looks for 401s and if so, refreshes the application (which redirects to the login page)
it’s odd cljs-http doesn’t support interceptors though. Surely you can add a “middleware” step somehow?
hey I have a question. I have a requriment for some ‘dynamic’ forms. where as opposed to say this from the form state demo
(defsc PhoneForm [this {:keys [:db/id ::phone-type root/dropdown] :as props}]
{:query [:db/id ::phone-type ::phone-number
{[:root/dropdown '_] (prim/get-query bs/Dropdown)} ;reusable dropdown
fs/form-config-join]
:form-fields #{::phone-number ::phone-type}
:ident [:phone/by-id :db/id]}
(dom/div :.form
(input-with-label this ::phone-number "Phone:" "10-digit phone number is required.")
(input-with-label this ::phone-type "Type:" ""
...
I can have some sort of DynForm
component or just a builder macro, that would read a form def (maybe returned from the server) perhaps like this:
{:form/name ..
:form/id :phone/id
:fields [{:key :phone/number :type :text :validations [....]} ...]
I’m trying to get my head around how this could get wired into the app db properly. A DynForm SC, could maybe use a dynamic query at the top level, but not sure if the form state stuff itself can be handled that way. If say created the entire defsc dynamically, not sure how it’s containing SC would keep things straight(defsc FormProto [this {:keys [which-tab]}]
{:query [:which-tab]
:initial-state {:which-tab :form-proto}}
(dom/div "FormProto"))
@njj are you using that inside a router?
if not, you can make an ident up
something like :ident (fn [] [:COMPONENT/by-id ::form-proto])
would work