This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-04
Channels
- # aleph (1)
- # announcements (7)
- # beginners (22)
- # calva (31)
- # cider (2)
- # clj-commons (1)
- # clj-http (2)
- # clj-kondo (10)
- # cljsrn (33)
- # clojure (18)
- # clojure-europe (7)
- # clojure-nl (3)
- # clojure-uk (2)
- # clojurescript (93)
- # depstar (3)
- # events (1)
- # figwheel-main (3)
- # fulcro (13)
- # graalvm (95)
- # graphql (1)
- # introduce-yourself (1)
- # lsp (92)
- # off-topic (2)
- # pathom (11)
- # releases (1)
- # shadow-cljs (33)
- # specter (6)
- # tools-deps (4)
- # vim (3)
- # web-security (1)
- # xtdb (7)
If I need to load some data by using df/load!
in defsc
, where is the right place to kick it off? For example, borrowing from minimalist tutorial:
(defsc FriendsList [_ props]
{:query [:list/people [df/marker-table :friends-list]] ;
:ident (fn [] [:list/id :friends])}
(let [marker (get props [df/marker-table :friends-list])] ;
(cond
(df/loading? marker) (dom/div "Loading...") ;
(df/failed? marker) (dom/div "Failed to load :-(")
:else (dom/div
(dom/h3 "Friends")
(map ui-person (:list/people props))))))
Should I add {:initial-state (df/load ...
would that make sense?Could you explain why you think you need to do this? Load typically happens 1. At app start, there where you mount your app (an init function?) 2. Upon user action, ie in onClick or similar or from a mutation 3. When you a component is first displayed - here optimally you'd use Fulcro dynamic routing but can also use React's componentDidMount life cycle method
I send an email to the user with the link to verify email like so: http://localhost:3000/verify?token=fa76c76e-b765-41d5-89de-2a8fc73ef932
So when user clicks on it, I want to grab the token parameter and attempt to verify the email, then provide success or failure notice.
Some ideas: • Since this is a pure verification (which you stored on the server), you could make a server-served HTML page for that URL, process the token, then show them a static result with a link to log in. • During app init, look at the URL and do the interaction. Track the state of that interaction and use a top-level root key to track progress, which you render via Root component
If you do 2, then I'd recommend a UISM to make it easier to code the sequence...and integrate it with your login/signup/password change parts of the app.
@tony.kay, thank you for advice, 2 is similar to normal methodology, will explore it.
@tony.kay Hi Tony! Regarding https://github.com/fulcrologic/fulcro/issues/484#issuecomment-911967463, the last line in this snippet confuses me:
(defn global-eql-transform
"Returns an EQL transform that removes `(pred k)` keywords from network requests."
[pred]
(fn [ast]
(let [mutation? (symbol? (:dispatch-key ast))
because, given the query '[(my-mutation)]
, the AST we will get here will be
{:type :root, :children [{:dispatch-key my-mutation, ...}]
i.e. the node we are checking in the fn is always the root and never the mutation itself.
So it seems the code is wrong and it should map over the (:children ast)
to add tempids to all... Or perhaps I am just missing something??FYI here is my proposed solution https://github.com/fulcrologic/fulcro/pull/486/files?diff=split&w=1 (I have to undo the unnecessary whitespace changes, therefore this diff ignores them)
It's because this function is handed an AST node from the middleware, not the entire AST
Try logging while using the transform in a live app . I don't remember what all you can get, but I do know that what was coded there works
A bonus question: Is for some reason the check (symbol? (:dispatch-key ast))
preferable to (= :call (:type ast))
?