Fork me on GitHub
#fulcro
<
2020-01-28
>
Jakub Holý (HolyJak)08:01:51

@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 ...?

kszabo09:01:17

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

👍 4
Jakub Holý (HolyJak)09:01:16

Thanks! Somehow I couldn't find a link from the book to its GH repo...

kszabo10:01:41

You are welcome! Yeah, adding a link to the source document in the intro would be a nice addition :))

tony.kay16:01:53

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 🙂

👍 4
fjolne12:01:54

@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

tony.kay17:01:31

Fulcro 3.1.8 deployed with inspect ws fix

tony.kay17:01:12

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

fjolne18:01:55

@tony.kay great, thanks! updated PR with inspect fix + readme about it

tony.kay18:01:26

merged, thx

levitanong12:01:10

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?

parrot 4
tony.kay17:01:32

the application ns is cljc…it is just an app.

👍 4
otwieracz14:01:42

I've got component like:

otwieracz14:01:54

(defsc TerminalBadge [_this {:terminal/keys [connector pin]}]
  {:query         [:terminal/id :terminal/connector :terminal/pin]
   :ident         :terminal/id}
  ...)

otwieracz14:01:08

hmm, just one second... 🙂

otwieracz14:01:47

OK, nevermind 🙂

😄 4
otwieracz18:01:48

(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)
  ...)

otwieracz18:01:04

Why does show is null?

thosmos20:01:05

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.

otwieracz18:01:37

Do I have to propagate this initial state back to the root?

otwieracz19:01:41

Sorry for this flood of questions - I've got hard time wrapping my head around Fulcro 😞

otwieracz19:01:30

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 :

otwieracz19:01:14

I must be doing something terribly wrong, I see I've got problems following the logic properly.

otwieracz19:01:14

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)

otwieracz19:01:05

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).

otwieracz19:01:49

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. 🙂

thosmos21:01:07

And line 58 should instead be:

(ui-add-connector-modal {:add-connector-modal/show add-modal-visible?}))))

thosmos21:01:09

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.

thosmos21:01:34

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!

thosmos21:01:13

in other words, somehow you’re loading your list of connectors into root instead of in the component that needs it

otwieracz06:01:40

Thank for your replies!

otwieracz06:01:49

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.

otwieracz06:01:04

And I didn't wanted to load them separately to every component with :target

otwieracz06:01:25

Because here I have this ConnectorsList in ConnectorsTab, but I expect it have things like ConnectorSelctor which will rely on the same data.

otwieracz06:01:46

So I think I'd rather avoid asking server multiple times for the same data.

otwieracz06:01:49

To re-state my question: how can I feed multiple components with on top level :connectors list?

otwieracz06:01:41

I can load to multiple targets, but any modification of the state is no longer local.. Like, "add connector" component will need to know each component to which it should add a connector.

thosmos17:01:16

Oh I think I see. Have you tried something like: :query [[:connectors '_]]

thosmos17:01:38

That’s a link to something at root from any component

otwieracz19:01:36

Where can I find anything about that syntax in documentation?

otwieracz19:01:08

Oh, I see, link queries