This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-28
Channels
- # babashka (28)
- # beginners (252)
- # bristol-clojurians (2)
- # calva (28)
- # cider (11)
- # clj-kondo (15)
- # cljs-dev (7)
- # clojure (378)
- # clojure-europe (4)
- # clojure-italy (4)
- # clojure-nl (3)
- # clojure-norway (4)
- # clojure-uk (32)
- # clojurescript (128)
- # cursive (39)
- # data-science (18)
- # docker (37)
- # figwheel-main (10)
- # fulcro (45)
- # ghostwheel (7)
- # graalvm (2)
- # hugsql (1)
- # jobs (2)
- # joker (5)
- # kaocha (5)
- # luminus (12)
- # off-topic (37)
- # onyx (4)
- # pathom (22)
- # pedestal (70)
- # re-frame (7)
- # reagent (30)
- # ring (4)
- # shadow-cljs (12)
- # spacemacs (1)
- # sql (26)
- # tools-deps (7)
- # vrac (2)
- # vscode (7)
- # xtdb (27)
@tony.kay I am trying to learn Fulcro and in the process discovering improvements to the docs that I'd appreciate so you are going to hear from me a little 🙂 Great work with the Fulcro ecosystem and documentation! I have some comments, typos, etc regarding the book - what is the best way to send those? Paste here or ...?
Usually the less work Tony has to do with it, the better 🙂 so providing a mergable PR for this document would be best IMO: https://github.com/fulcrologic/fulcro-developer-guide/blob/master/DevelopersGuide.adoc
Thanks! Somehow I couldn't find a link from the book to its GH repo...
You are welcome! Yeah, adding a link to the source document in the intro would be a nice addition :))
What they said is correct. If you have anything significant beyond typo fixes or links then it might make sense to ask questions about them first…otherwise, PR away 🙂
@tony.kay CSRF for web + cookies for native https://github.com/fulcrologic/fulcro-native-template/pull/5 latest Inspect Electron won’t work nicely with native https://github.com/fulcrologic/fulcro-native-template/issues/6 which could be easily fixed with a bit of inspect-ws customization https://github.com/fulcrologic/fulcro/pull/366 i’d make another PR with inspect for native fix if those are merged
If you want to update your PR to use the new 3.1.8 inspect-ws preload, then it should be all set I would thing @UDQ2UEPMY
Hallo! There is a reference to binding *app*
when performing SSR here: http://book.fulcrologic.com/#_rendering_with_initial_state
but I can’t find anything on what exactly this should look like in the server. Is one expected to make any data structure from scratch that conforms to the ::app spec?
(defsc TerminalBadge [_this {:terminal/keys [connector pin]}]
{:query [:terminal/id :terminal/connector :terminal/pin]
:ident :terminal/id}
...)
(defsc AddConnectorModal [_this {:add-connector-modal/keys [show]}]
{:query [:add-connector-modal/id :add-connector-modal/show]
:ident (fn [] [:add-connector-modal/id :singleton])
:initial-state {:add-connector-modal/show true}}
(js/console.log "Show is" show)
...)
in order for show to not be null, the parents all the way to root would need to load its initial-state in their initial-state … so the parent would need to have something like:
(defsc Parent [this props]
{:query [{:c-modal (comp/get-query AddConnectorModal)}]
:initial-state {:c-modal {}}})
and the parent of Parent
would need to have it in its initial-state, etc
OR
In a mutation you can handle saving that into state your self by calling (comp/get-initial-state AddConnectorModal)
and saving that into state where it should go …
In other words, :initial-state
is just a convenience for composing initial state in at app startup … but I find it’s tricky when dealing with lists of things, where that initial state isn’t really there on app start, and I need to take a more intentional approach to getting it into app-state.Sorry for this flood of questions - I've got hard time wrapping my head around Fulcro 😞
I am trying to refactor my sample app a bit, but I've got problems with general approach how to organize properties, pass them, etc.. I don't even know truly how to ask question and why it is not working, but if somebody will have a chance to look why my connectors
returns null
:
https://github.com/otwieracz/wires/blob/master/src/main/wires/ui/connectors.cljs#L54
I must be doing something terribly wrong, I see I've got problems following the logic properly.
I wanted to separate everything from connectors
tab into ConnectorsTab
component, but resolve only top level :connectors
with resolver (as other state is UI-local)
Just one note, https://github.com/otwieracz/wires/blob/master/src/main/wires/ui/connectors.cljs#L53 is actually true
not null
, as indicated by comment (there's true
on screenshot).
If somebody could have a look at this code to point out any general errors in approach, etc, I'd be very grateful.. But I am completely aware that's a lot of somebody's time I am asking for. 🙂
You need to add a key that refers to AddConnectorModal
into the query of ConnectorsTab
here: https://github.com/otwieracz/wires/blob/86bd2953b00fa14b839e0fedf6ae28b277f28003/src/main/wires/ui/connectors.cljs#L49 and also include that key in the :initial-state
here: https://github.com/otwieracz/wires/blob/86bd2953b00fa14b839e0fedf6ae28b277f28003/src/main/wires/ui/connectors.cljs#L52
And line 58 should instead be:
(ui-add-connector-modal {:add-connector-modal/show add-modal-visible?}))))
In fact that change to 58 should get the component visible, but it would be disconnected from state because there’d be nothing where its ident is pointing unless you add it to its parent’s query and initial-state. But as of right now, there’s no need for that component to have an ident, so it could just run from props that get passed to its factory … I would say it only needs an ident if it should have state that persists between different uses of it at different times. But because it is a transitory component (as of now) it doesn’t need an ident and can just exist almost as a functional component … and it could be a purely functional component, but using defsc
make sure it only gets re-rendered when its props change.
As for :connectors
in ConnectorsTab being null, it looks like you have a list of edges in the root of app state, so it appears that when you do the load, you need to add a :target [:connectors-tab :singleton :connectors]
to the load!
in other words, somehow you’re loading your list of connectors into root instead of in the component that needs it
Let me explain: I wanted to use connectors
instead of connectors-tab/connectors
in https://github.com/otwieracz/wires/blob/master/src/main/wires/ui/connectors.cljs#L47 beucase I expected multiple components to use one, already loaded root level :connectors
list.
Because here I have this ConnectorsList
in ConnectorsTab
, but I expect it have things like ConnectorSelctor
which will rely on the same data.
To re-state my question: how can I feed multiple components with on top level :connectors
list?