Fork me on GitHub
#fulcro
<
2021-10-19
>
bmaddy01:10:06

Does anyone know of any fulcro rad templates that are in the public domain? I'd love to start a new closed-source work project from a template if possible.

tony.kay01:10:23

The fulcro-rad-demo is basically that

bmaddy01:10:47

I thought the MIT License meant that anyone would be able to share the code - i.e. other developer employees could legally share the codebase with competitors if they wanted. I could be way off here, all of these licenses confuse me.

lsenjov04:10:06

Yup, MIT is “do what you want with it, just reference me and don’t blame me for anything”. It is not a share-alike like the EPL

genekim21:10:30

https://github.com/realgenekim/rss-reader-fulcro-demo/tree/gene-stories Here's an RSS reader I built on top of the Fulcro RAD demo. There's a link to it running in Google Cloud Run, too.

Timofey Sitnikov11:10:22

I am using Fulcro Template to learn Fulcro. I am attempting to change email on the client side in the ok-action of defmutation. The data I am attempting to change is buried, see attached image, it is at #3. Are there helpers to easily access and update the :session/account/email value?

tony.kay14:10:13

um...`update-in` and assoc-in? It's never more than 3-deep. 😄

tony.kay14:10:25

perhaps I'm mis-understanding your question/confusion. It's a normalized db...perhaps you're thinking you have to follow the path in the db for some reason?

tony.kay15:10:26

oh, I see...you've not properly normalized your database.

tony.kay15:10:31

Several things: 1. You should be using fulcro-inspect to view the current state. 2. Your code is clearly wrong from this screen shot. Not sure what you're doing, but you're clearly not following the basic directions for query/ident/initial state.

Timofey Sitnikov17:10:52

Thank you @U0CKQ19AQ, my previous example is modification of Fulcro Template, so below is the vanilla Fulcro Template client db: I am trying to update the [:component/id :session :account/name] variable. So, I should be able to do something like: (get-in @state [:component/id :session :account/name]) , or am I confusing everything?

tony.kay18:10:06

That looks better. Yes, you can change it in the mutation with (swap! state assoc-in [:component/id :session :account/name] "new name")

1
tony.kay15:10:05

If you were doing (2) correctly then you would not need a helper. It's (half of) the entire point of Fulcro 🙂

tony.kay16:10:03

Fulcro RAD 1.0.30 released. This version reverts the changes in 1.0.29. The js-joda upgrade breaks things in downstream usage. I know how to fix it and shrink the overall deployment size, but it's not work I have time for right now. I'll add it to a "good for beginning contributors" issue on github. NOTE: 1.0.30 also includes a hot code reload improvement for faster dev in large projects. Re-evaluating a defattr will now cause it to refresh, even if you closed over the value of it somewhere. This is roughly equivalent to using mutable data for attributes, but in the case of a defattr (which never reloads at runtime) it is only a dev-time convenience, and is not meant to be a production-time feature. To that end I will probably add some kind of flag for disabling it altogether in production builds.

tony.kay22:10:07

I'm trying like hell to get rid of tick in my app. It does not work well for me, and is part of the reason I'm in this locale-hell....I actually just hand-coded the solution to that issue, and it is MUCH better.

tony.kay22:10:58

tick uses cljc.java-time, which is just a thin wrapper over js-joda...and js-joda is excellent except for the locale and formatting stuff...code bloat and package.json hell.

tony.kay22:10:48

I prefer using cljc.java-time directly. Matches the Java API, which means very easy to find answers on Stack Overflow, well-defined API, etc. etc. Tick is trying to be too clever IMO. You never know what the heck you have, and that leads to a lot of bugs.

1
sheluchin22:10:29

Thanks for the background. I just wanted to put it on your radar in case it offered a bit of a shortcut. I haven't used it myself, but I'll trust your advice and stick to java-time instead of reaching for wrappers.

tony.kay04:10:14

I want to like it, and I'm sure it works for some people just fine. But I've seen it used and yanked from two major projects at this point.

roklenarcic19:10:10

So fulcro backend returns js/Date values via transit (or rather transit decodes it to js Date)…. and we have cljc.java-time… is there some way to convert values automatically to cljc.java-time values? I have tried to find function that converts js/Date to cljc.java-time Instant and haven’t found any

tony.kay20:10:24

So, I highly recommend that you keep your data types identical between front/back end. Transit, as you saw, uses standard js dates and jvm dates. I always leave those in that form. It's also why I added Big.js and the math ns so I could get equivalent support for bigdecimal on the front-end.

tony.kay20:10:14

The functions in date-time are meant to help you do common tasks with js Dates related to front-end work. I would not put cljc.java-time js Instant in your state, because then you're going to have to add a transit handler for it. You can, of course, do that, but then ALL of your database queries etc are going to have to translate things around. If you want to hack transit and change the encoding of date on the back end to Instant on the front you can do it (I think...don't know about overrides), but I think you're just going to end up confusing yourself.

tony.kay20:10:19

Keep the data model simple and isomorphic front-to-back...If you ahve to do some temporary thing (display a date in a locale/time zone aware fashion) then use UI adapters for that...don't munge the data on the wire.

sheluchin17:10:47

I notice that RAD demo repo doesn't have issues enabled. Is that intentional? I wanted to create an issue noting that Crux needs to be upgraded to xtdb there since they rebranded and it might be confusing for new users. There's a bit of refactoring required beyond just find/replace, but not too much.

Piotr Roterski19:10:07

hey, I made that crux integration and I'll push the upgrade shortly 🙂 sorry and thanks for the reminder

sheluchin19:10:37

@UHA0AQZ2M No sir, thank you! Your integration was very helpful. I followed your initial PR in setting up Crux in my own Fulcro project.

😊 1
tony.kay18:10:32

I'm not maintaining the alternate db support for the demo. If you see a problem and want to fix it, test it heavily, and send a PR that's fine. Too much to do.

👍 1
sheluchin18:10:18

Thanks. I'm guessing it'll take me a few weeks of tinkering to get more comfortable with RAD. I liked what I read in the intro.

Tyler Nisonoff19:10:02

is it generally considered bad practice to call m/set-value! inside a mutation definition? (Should one strive to directly modify the state-map if possible, or does the transaction system somehow know when its called inside a mutation and do the right thing?)

sheluchin20:10:36

The docstring suggests you should only use it for UI-related data. That doesn't directly answer your question, but perhaps it helps. In the few places I'm using that function, I usually just combine it with transact! calls by wrapping both in an and or something.

tony.kay22:10:03

so, here's the deal: the set-value! isn't going to even work from inside a mutation unless you set :ref, and it triggers an additional transaction itself...so it is kinda silly.

tony.kay22:10:21

it's ok to trigger a new tx from a mutation...that's fine, though messy and harder to trace (since that makes it an async execution path. You're MUCH better off writing a mutation helper instead, and using that. See https://book.fulcrologic.com/#_mutation_helpers

tony.kay22:10:00

NOTE: ref in env is the ident of the component that invoked the transaction in which the mutation is running, which is how set-value! figures things out...you can, of course, do the same.

tony.kay22:10:02

and the other fun helpers in that ns.

Tyler Nisonoff22:10:59

great thank you!

roklenarcic21:10:37

What’s the best way to add “computed” columns to RAD report? Something that would get its own column, but it is derived completely from other queried data. (and I’d prefer not to have in DB)

tony.kay22:10:53

Make a resolver for it, and add it to ro/row-query-inclusion or specify ro/BodyItem and write the row query yourself along with rendering of it.

tony.kay22:10:16

depends on if you want server computing it or UI (based on what's already there).