This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-30
Channels
- # announcements (4)
- # babashka (3)
- # beginners (5)
- # calva (20)
- # cider (12)
- # clj-kondo (7)
- # cljs-dev (2)
- # clojure (76)
- # clojure-uk (4)
- # clojuredesign-podcast (8)
- # clojurescript (18)
- # clojutre (1)
- # cursive (9)
- # data-science (27)
- # datomic (2)
- # fulcro (32)
- # graalvm (4)
- # jackdaw (5)
- # jobs (2)
- # joker (5)
- # lumo (20)
- # off-topic (18)
- # pathom (3)
- # shadow-cljs (18)
- # sql (5)
- # tools-deps (1)
- # vim (11)
I'm playing around with fulcro-rad based off the example code and ran into an issue with defsc-form
and wondering if it's just user error on my end. :form-fields
ends up empty on the generated component options because the macro in form.cljc
uses the clj
attribute registry during macro expansion and since my ui is a cljs
file only the cljs
version of the attribute registry has been populated. If I (:require-macros [my-app.model.account])
in my ui it fixes the issue (because when the defattr
forms are evaluated as Clojure they populate the clj
registry used by the defsc-form
macro). I'm curious how the example code is working because it does not :require-macros
That is all experimental code, and will likely change, and will be documented when stable…but also see https://blog.fikesfarm.com/posts/2016-03-01-clojurescript-macro-sugar.html which might have something to do with your question…I don’t have time to analyze your case 🙂
I understand what is going on and that the code is experimental. I will try and contribute a PR if I can get the macro to work in cljs files without evaluating the defattr
forms in the jvm context as well as cljs. The use of :require-macros
is just a hack to get the code working and I think this is the basic usecase of defsc-form
. Thank you for the time and effort you put into fulcro
Has anyone deployed a fulcro app to datomic ions while using timbre? I'm running up against this error; not really sure what's going on: https://clojurians.slack.com/archives/C03RZMDSH/p1575089762024000
Hello, I'm getting an Unknown app state mutation. Have you required the file with your mutations? highlight-key-green
error I can't figure out. My mutation looks like this
(defmutation highlight-key-green [{:keys [octave key]}]
(action [{:keys [state]}]
(swap! state
assoc-in [:keyboard/green-key]
{:keyboard/octave octave
:keyboard/key key})))
and I'm calling it like this
app.client.core> (comp/transact! app '[(highlight-key-green {:octave 0 :key 0})])
The app.client.core
namespace has the following ns clause
(ns app.client.core
(:require [com.fulcrologic.fulcro.application :as app]
[com.fulcrologic.fulcro.dom :as dom]
[com.fulcrologic.fulcro.components :as comp :refer [defsc]]
[sablono.core :as sablono]
[app.client.keyboard :refer [PianoKeyboard ui-keyboard]]
[app.client.mutations :refer [highlight-key-green highlight-key-red]]))
I'm guessing I'm doing something very obvious wrong, but I can't figure out what it is.Use backquote instead of regular quote
Or no quote at all
That got rid of the error. Thanks.
With back quoting you can get around circular requires, invoking the sym directly requires you reference the mutation sym like calling a function
Either way it needs to be a namespace qualified symbol
OK. I will remember that.
Bear with me, I have another beginner question. I have a component with the following query {:query [:keyboard/green-key :keyboard/red-key]}
. My state looks like this.
app.client.core> (app/current-state app)
{:keyboard/green-key {:keyboard/octave 1, :keyboard/key 1}, :com.fulcrologic.fulcro.application/active-remotes #{}, :keyboard/red-key {:keyboard/octave 2, :keyboard/key 1}}
Still, when I print out the components state, it is an empty map.Querys start from the root. The query works only on the root Component.
Thank you, it works now.
Is my usage correct? I use this df/load!
to load the data for this component, but it looks a little verbose here. Especially I have to specify :target
(which should be current component) and Customer
(which already in my query).
(defsc CustomerModule [this {:keys [customers name-filter payment-type] :as props}]
{:query [{:customers (comp/get-query Customer)}
:name-filter
:payment-type]
:ident (fn [] [:component/id :customer-module])
:initial-state {:customers []
:name-filter ""
:payment-type "all"}
:route-segment ["customer"]
:will-enter (fn [app route-params]
(df/load! app :customers Customer
{:target [:component/id :customer-module :customers]})
(dr/route-immediate [:component/id :customer-module]))})
I want to know if there's way to simplify how I load data for this particular component.
And my :will-enter
will always run 3 times for each time I change the route, but the render will happen only once. There maybe something wrong with my code, but don't know how to investigate deeper.For loading data
use :componentDidMount
, don’t do a df/load in :will-enter
You can load in will-enter but you should use route-defered
and target-ready afterwards. Will-enter will maybe be called more than once.
@U6Y72LQ4A @U4VT24ZM3 thanks!
Hi, @U4VT24ZM3
How can I do two df/load!
before target-ready
?
I saw in the example in document, it shows use post-mutation and post-mutation-params in df/load!
.
You can add call target-ready from inside your mutation. But I recommend that you think about what you actually have to load to display the Routing target. Load additional stuff elsewhere. If you need everything, than you should reconsider your query.
@tony.kay is it possible to make pull requests on the book? I'm not sure where the source is for it. Just finding some little typo's that would be easy to fix with a pull request.
The text of the book itself is in https://github.com/fulcrologic/fulcro-developer-guide/blob/master/DevelopersGuide.adoc
PRs definitely welcome on that front 🙂
Is there any place to read the Fulcro book in smaller sections, instead of having everything on one page? It's pretty slow to load on mobile, especially after I add some annotations to the page.
I don’t think it’s available
The slow-loading is likely due in-part to the inline live code examples.
On my iPhone, I was able to load the book in Safari, then use the share-sheet to open it with Books. This converted it into a static PDF in Books, albeit with a layout not optimized for mobile reading
Be a great contribution: I don’t have time to maintain derivative works, but a mobile-friendly version of the book would be nice to have if someone wants to figure out how to make that happen and keep it up to date without any overhead for me.
@U066U8JQJ’s pathom docs recently did this, maybe @UPWHQK562 you could follow his example