Fork me on GitHub
#fulcro
<
2020-07-08
>
lgessler04:07:38

anybody have a favorite way to chunk code? ignoring the more boilerplatey stuff i've been putting my components in a ui folder and i have a models folder where i put pathom resolvers and mutations in .clj files and fulcro mutations and uisms in .cljs files. it feels OK so far but my project's still pretty small

Jakub Holý (HolyJak)07:07:31

I do the same on this smallish project but on a bigger one I would prefer top-level functional areas (such as checkout, product-discovery , product-details ) and have UI, models, and resolvers for each inside (plus a place for the shared stuff such as the parser and the landing page UI). Java liked to split code into views, controllers, services etc - but I think it works badly on bigger projects. There it makes sense to split based on the business are rather than technical role.

zilti07:07:30

So far I am just using the RAD Demo folder structure, honestly... Works fine for now. But I can see doing the switch as hoyjak describes

zilti07:07:37

We have this other project here, a bit older, in PHP, which is using Symfony and split into model, view, layer, controller, and it gets so very cumbersome making even the smallest change, because for everything you have to go make changes in at least four files

folcon11:07:39

Our little fulcro study group, is meeting again in a few mins =)…

folcon11:07:28

Sorry I missed last week to anyone who wanted to join in, something came up >_<… Link is here: https://hangouts.google.com/call/Vx0_5pVM3yYfClYUSCFQACEI Pinging: @U2J4FRT2T @U0DUNNKT2 @U0522TWDA @U49U72C4V

folcon13:07:24

@UCJCPTW8J Thanks for joining, very interesting to speak to you…

👍 3
tony.kay15:07:55

Hey @U2J4FRT2T @U0DUNNKT2 @U0522TWDA @U49U72C4V @UCJCPTW8J, if you meet a bit later some time, I’d be glad to join for a bit. Might be most useful if you have more general questions that help in global understanding, but I can talk about details of features as well.

👍 9
lgessler16:07:57

sorry i couldn't make it today, i'm a grad student and our main conference is this week. looking forward to next meeting 🙂

folcon14:07:51

Hey @U0CKQ19AQ, thanks for this 😃... When you say later what time do you mean?

tony.kay14:07:23

well, I tend not to be up and functioning until 4PM GMT, and then I’m up for about 15-16 hrs.

tony.kay16:07:58

The “endpoints” of the day are generally easier for me to deal with, since I’m not in the middle of anything then

folcon17:07:31

Ok, I've been a bit busy today which is why I've not setup a call, but if you're fine with it, who else would like a meeting around 4pm GMT next week? (22nd)

tony.kay17:07:18

ok, yeah, I can do that. Also gives ppl time to prepare questions. I think an expectation should be that I’m not going to be able to comprehend other people’s existing code in such a short time window. Targeted discussion around general topics or namespaces that ppl are struggling with understanding is where I’ll be most able to help, I think.

folcon12:07:26

Hi @U0CKQ19AQ, I have someone who appears in all the study group conversations with me and he’s not available next week, would doing it at 4pm GMT on the 29th work for you instead? =)… I’ll be looking to prepare questions and will ask others to do the same!

Adrian Smith12:07:20

I'd appreciate a deep dive into :query :ident because I still don't feel confident about what to put in there and when to use (merge!) (merge-component) (df/load!) both in terms of when those calls take place in an apps lifecycle and how to know which one to use, are the sessions recorded? unfortunately I'm usually at work when these happen

3
folcon15:07:05

If you have any specific questions / examples that you'd like us to get feedback on @UCJCPTW8J let me know, I'll make sure they get covered if Tony doesn't answer them here 😃...

tony.kay15:07:13

yes, I can do that

tony.kay18:07:34

Make sure you confirm it if that’s what you want to do, so I can add it to my calendar

folcon14:07:15

Definitely will =)…

Joe R. Smith13:07:44

Is there an example of Fulcro 3 dynamic routing + Bidi (for html5 history)?

Chris O’Donnell14:07:53

Doesn't use bidi, but you should be able to plug it in: https://chrisodonnell.dev/posts/giftlist/routing/

👍 3
tony.kay15:07:54

Fulcro RAD Demo…not only does it support history, it records route parameters into the URL so things like report parameters can be bookmarked.

👍 3
lgessler15:07:26

here's https://github.com/lgessler/glam/blob/master/src/main/glam/client/router.cljs based on https://github.com/dvingo/dv.fulcro-template. It's kind of messy (especially the on-match function) but it does what I want it to for now

👍 3
dvingo15:07:05

yea, that's not fully baked. especially for dealing with nested fulcro segments. once i have that need in a project I'll have to address it.

tony.kay15:07:35

In fact, you might consider the Fulcro RAD routing to be a layer on top of D.R. that supports the idea of history and “back” for all platforms (web/native).

tony.kay15:07:19

it’s pluggable, and in case you’re misunderstanding RAD: it isn’t something different, it’s just predefined patterns written in Fulcro.

lgessler16:07:10

@U0CKQ19AQ i didn't realize it was pluggable, i should check it out then!

Chris O’Donnell16:07:51

Rad routing is definitely more robust than the blog example, but the blog example might be a nicer starting point to understand how the pieces fit together.

murtaza5208:07:11

@U0DUNNKT2 which blog example are you referring to ?

magra15:07:38

Hi, my app ran fine until yesterday. Today I updated deps from shadow-cljs 2.10.12 to 2.10.14. rollback solved it once. Then I tried to make the error reproducable. Now I can not get it to work again. I cleaned .m2, ressources/public/js, target, classes. My builds on the template. calling routing to start in init starts the errors. If I comment this out then mounting the app calls the errors. The state machine of the dynamic router won't be loaded. All the errors are similar.

ERROR [com.fulcrologic.guardrails.core:54] -  Error: Unable to resolve spec: :com.fulcrologic.fulcro.ui-state-machines/fulcro-app
    at Object.cljs$spec$alpha$reg_resolve_BANG_ [as reg_resolve_BANG_] (alpha.cljs:71)
    at Object.eval [as cljs$spec$alpha$Specize$specize_STAR_$arity$2] (alpha.cljs:137)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (alpha.cljs:132)
    at Object.cljs$spec$alpha$specize_STAR_ [as specize_STAR_] (alpha.cljs:131)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (alpha.cljs:161)
    at eval (core.cljs:4741)
    at eval (core.cljs:4742)
    at Object.eval [as sval] (core.cljs:3439)
    at Object.eval [as cljs$core$ISeqable$_seq$arity$1] (core.cljs:3496)
    at Object.cljs$core$seq [as seq] (core.cljs:1234) BUG: Internal error in expound or clojure spec.
So guardrails throws BUG: internal error in expound or clojure spec. I am clueless how to go about this.

magra15:07:23

When I eval the errors read a bit differently than in the log. Evaling app/mount returns #object[Error Error: Unable to resolve spec: :com.fulcrologic.fulcro.ui-state-machines/env].

magra15:07:09

Has anyoune seen this before?

tony.kay16:07:39

@magra So, if you disable spec generation in guardrails this can happen…it is a combo of options that should not be supported, actually.

tony.kay16:07:53

there is an emit-spec? option, which should be set to true if GR is enabled

tony.kay16:07:34

you can also change the GR option throw? to be false so it just emits warnings instead of throwing (which is what I do in dev).

tony.kay16:07:48

I only use throw? true in tests (because there is never a good reason in my experience to throw in clj/cljs due to a spec failure that already can print a stack trace)

tony.kay16:07:59

More in depth: >def is like s/def, but can optionally NOT emit a spec. This is to make cljs builds smaller…however, if you tell it not to emit specs and also turn on spec checking, then you’ll get that error. Not sure why the upgrade gets you, but I suspect your deps tree changed….I thing G.R. had a bug where it was ignoring the emit option or something that got fixed, and you probably just got a newer version.

tony.kay16:07:25

this is unrelated to shadow itself

dvingo16:07:57

@magneh i think you have to switch this to true

dvingo16:07:26

@magra wrong name ...

magra16:07:35

Yep, that worked. Thanks!!!

magra16:07:38

Wow! fixing it in guardrails.edn was not enough. I had to change shadow-cljs.edn from the empty map to {:throw? false :emit-spec? true}.

tony.kay16:07:02

now that is strange. That map should override the edn file.

magra16:07:03

Thank you Toni!!!!

magra16:07:41

If this is not specific to my setup, but a new dependency then the template might trap up newcomers from now on.

tony.kay16:07:32

I’ll update the template…it’s long overdue

magra16:07:33

Thank you again. I searched for a few hours and would have wasted another day since I had ruled that out and was barking up the wrong tree.

magra16:07:35

I tried old Versions from a week ago so I had ruled out a misconfiguration.

magra16:07:43

So I had an invalid guardrails.edn with a good override from the start and something stopped this override from working.

tony.kay16:07:42

I’ve updated the Fulcro template: https://github.com/fulcrologic/fulcro-template to latest dependencies and tested everything (I think). I had no problem getting GR from config file to work properly.

🎊 6
❤️ 3
tony.kay16:07:32

I’ve added a comment to the README about how the RAD demo might be a good starting point these days instead of the low-level template.

tony.kay16:07:02

RAD just gives you more…but all of it is optional. But I can’t imagine why you wouldn’t want at least some of it.

magra16:07:26

I must have missed some stale state then after changing the .edn file.

tony.kay17:07:27

https://clojurescriptpodcast.com/ Part 2 of Fulcro discussion on cljs podcast is out today it seems

🎧 6
👏 6
pithyless19:07:47

Looking forward to part 3! You’re hitting a lot of great talking points in such a condensed format.

JAtkins19:07:20

Am I crazy, or is there something weird with singletons (constant :ident) and workspaces?

JAtkins19:07:03

Any time I add a constant ident to a component that is at the root of a defcard the ui disappears (both with and without :wrap-root?)

tony.kay19:07:27

initial state?

tony.kay19:07:38

if it has an ident, you have to use wrap root true

tony.kay19:07:50

and you need to have initial state for it

JAtkins19:07:25

(defsc cool [this {:keys [] :as props}]
  {:query []
   :ident (fn [] [:component/id :cool])
   :initial-state {}} ;; tried both with and without initial state being empty
  (dom/div "HI"))

(ws/defcard CoolCard
  (ct.fulcro/fulcro-card
    {::ct.fulcro/root       cool
     ;::ct.fulcro/initial-state {}
     ::ct.fulcro/wrap-root? false ;; tried both with and without :wrap-root?
     ::ct.fulcro/app        {:optimized-render! kr2/render!}
     }))

JAtkins19:07:44

All 4 scenarios are blank for me

tony.kay19:07:18

you didn’t query for anything

tony.kay19:07:49

why give it an ident if there is nothing to get, and if there is nothing to get, the wrapper might short-circuit….I didn’t write workspaces, so I don’t know internals of what it does…

JAtkins19:07:16

Ok. I might dig deeper here to see what's up. If I find that it's a bug in workspaces I'll make a pr against ws3

JAtkins19:07:22

(adding a query doesn't seem to help fwiw)