This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-28
Channels
- # aleph (48)
- # announcements (3)
- # bangalore-clj (1)
- # beginners (131)
- # cider (30)
- # cljdoc (6)
- # cljs-dev (53)
- # cljsrn (24)
- # clojure (312)
- # clojure-austin (2)
- # clojure-europe (4)
- # clojure-finland (6)
- # clojure-nl (24)
- # clojure-spec (24)
- # clojure-uk (66)
- # clojurescript (185)
- # core-async (46)
- # cursive (10)
- # data-science (9)
- # datomic (15)
- # devcards (2)
- # emacs (50)
- # fulcro (28)
- # jobs (1)
- # jobs-discuss (2)
- # kaocha (11)
- # lein-figwheel (12)
- # nyc (1)
- # off-topic (105)
- # other-languages (80)
- # pedestal (6)
- # re-frame (50)
- # reagent (5)
- # reitit (1)
- # remote-jobs (2)
- # ring (10)
- # rum (1)
- # shadow-cljs (10)
- # spacemacs (19)
Hi, I could use some guidance, please.
I am trying to implement the link query as in the developers guide chapter 5.8.
If I use it on root like so
[ {:current-user (prim/get-query Person)} ]
it works like a charme.
If I use it on a component inside nested routers like so
[ {[:current-user '_] (prim/get-query Person)} ]
it works in the ui but the query gets sent to the server, which
doesn't like this.
Where/how is the idiomatic way to handle this?
Haven't tried it on link props but should work the without
option in loads http://book.fulcrologic.com/#LoadOptions
Also this for more complex scenarious http://book.fulcrologic.com/#_morphing_mutations
@U3LP7DWPR Thanks! I will try that!
@U3LP7DWPR without worked like a charm! Thanks!
@U15BH4U4V You're welcome 🙂
You can also use the :ui/
prefix which prevents the query from being sent to the server instead of using without
in a load
You can also use a new option when you build the client that lets you transform queries before they’re sent…and include a standard elision set. See make-fulcro-client
docstring:
:query-transform-default
(optional) A (fn [query] query) that is used as the default :update-query
for data-detch/load parameters.
This can be used to customize things like preventing certain keywords from ever appearing in the remote version of a
component’s query. See fulcro.client.elide-query-nodes
for an idea of a common helper.
hello, when using a :css []
in a component, do i have access to the value? Can i have css that changes depending on the value of the component?
or do i have to define different css classes to begin with and use appropriate class name for the dom element ?
I was trying to do something like this (seems like the values are not accessible there)
(defsc Person [this ;; this
{:keys [person/name person/age]} ;; props
{:keys [onDelete]} ;; computed (for callbacks)
{:keys [person] :as css-name-map}]
{:initial-state (fn [{:keys [name age] :as params}] {:person/name name :person/age age})
:ident (fn [] [::id :person/name])
:query [:person/name :person/age]
:css [[:.person (merge {
:background-color "lightgrey"
}
(if (> 50 age) {:border-bottom "none"}))]]}
(dom/li
(dom/div #js {:className person}
(dom/h5 (str name " (age: " age ") ")
(dom/button {:onClick #(onDelete name)} "X")))))
I was wondering what is the best way to achieve this dynamic css based on the value of the component
Personally going with having multipe classes and just selecting them on the component {:classnames []}
based on props. Works well with the ideea of caching them so you don't pay the perf penalty when props change. For simple stuff I sometimes just add {:style {:color color}}
directly on the element.
yes, i ended up with doing the same, where i define multiple classes and then use the appropriate class based on the value
On that topic, case u missed it , some nice ideas here https://medium.com/@wilkerlucio/a-guide-to-organizing-styles-on-fulcro-apps-b280d2dfee6b
This may be a foolish question coming from a novice so please take it easy 🙂 When working with fulcro, how do you create components for composed objects that are not created as fulcro components? For example, if there was a library that creates a "Grid" Record object which has a collection of "Cells" record objects. And say there is some factory function in the library which when called can create a pre-initialized "Grid" object, how do i use them in a fulcro app? Do I still defsc
a Cell component and another Grid component or just a Grid
component and use the grid record as value without a cell component at all?
I want to keep "behaviors" for these object along with them, so i feel like it makes sense to create two components Cell
and Grid
, but I am lost on how do I work with the data in these components
Guess it depends on u're use-case and stuff. Not really sure I understand what you're trying to do. If you just use it at the beginning you could just put the data that it generates in the fulcro state when the app starts client-did-mount
with a transaction.
Yes i am reading it 🙂 Thank you so much for the detailed book. I am actually confused on how to properly used clojurescript datastructures in my app. Lets say I already have a clojure(script) namespace which creates a Grid
record that has a list of another records Cell
. Now to visualize it in the UI i think i will be creating Cell
component and a Grid
component as well. Is it correct way of doing things? I will probably have something tomorrow or over weekend to work on an example. Having hard time to find time working on clojure/script since this is not used at my workplace at all 😛
@U3MRWH35M Yep this is fine. I would use defsc for every component; the question is more whether those components should have an ident or not