fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
wilkerlucio 2021-06-21T00:16:45.222500Z

hehe, having some fun with this, prob gonna do a post in the next week 🙂

tony.kay 2021-06-21T01:02:21.222700Z

It's no different. You still create a Fulcro app for using transact

tony.kay 2021-06-21T01:02:30.222900Z

everything is CLJC

tony.kay 2021-06-21T01:02:56.223100Z

so, if you're doing server-side rendering you can start the app headless, run your mutations, and then pull the state from the atom and send that to the client.

tony.kay 2021-06-21T01:03:38.223300Z

If you mean you want to run the client mutation on the server for something else, what is that something else? Or do you mean you need to run a server-side mutation? If that's what you mean, and you're using pathom, you call the parser instead of transact.

tony.kay 2021-06-21T01:04:25.223500Z

good to hear. Let me know any other thought

Timofey Sitnikov 2021-06-21T02:05:17.223700Z

@tony.kay My question is probably a bit more elementary. I cannot figure out in Fulcro Template, if I try to run components/transact! what do I use for the app-or-comp argument as in the line below? https://github.com/fulcrologic/fulcro/blob/5277886b86ef3502342e9e1ff07dbedfe3793bdc/src/main/com/fulcrologic/fulcro/components.cljc#L792

tony.kay 2021-06-21T02:05:58.224Z

A Fulcro app

tony.kay 2021-06-21T02:07:09.224200Z

https://book.fulcrologic.com/#_server_side_rendering

tony.kay 2021-06-21T02:10:18.224400Z

you need to be more explicit about why you want to call transact on the server side

tony.kay 2021-06-21T02:11:40.224600Z

If you mean you just want to cause that mutation to run AS IF you'd called it on the client, then you need to invoke your middleware parser on the transaction

tony.kay 2021-06-21T02:13:10.224800Z

If that's what you want, then after starting the server, you can run:

Timofey Sitnikov 2021-06-21T02:13:14.225Z

For development in REPL, I would like to develop a server side mutation, make sure the output is what I expect it to be. So if I try to run a mutation in Fulcro Template on the client side, I do this:

(comp/transact! SPA [(login {:username "john" :password "mysecurepassword"})]))
On the client side, the app-ro-comp is defined here: https://github.com/fulcrologic/fulcro-template/blob/a169b0ab50c0b390ac5efe24e307d371ec2f2bd3/src/main/app/application.cljs#L13 It is the SPA variable, What do I use on the server side instead of SPA?

tony.kay 2021-06-21T02:14:35.225400Z

(app.server-components.pathom/parser {} '[(app.model.session/login {...})])

tony.kay 2021-06-21T02:15:12.225600Z

transact! does not run the server side stuff. The middleware receives it as a EDN and runs the parser

tony.kay 2021-06-21T02:15:20.225800Z

so, calling the parser is probably what you're wanting?

tony.kay 2021-06-21T02:15:37.226Z

if so, define your own dev helper that just runs some transaction on the parser like above

Timofey Sitnikov 2021-06-21T02:16:06.226200Z

Ahh, OK, yes I think I understand. Will try it.

tony.kay 2021-06-21T02:16:50.226400Z

The map, of course, is the env that resolvers/mutations on server side get as env

tony.kay 2021-06-21T02:17:53.226600Z

server mutations and resolvers in pathom 2.x are just maps, and one of the keys is the actual resolver fn, which you could also just directly call

tony.kay 2021-06-21T02:18:55.226800Z

What I usually do is define the functionality in a regular function that can be easily unit tested, and then call that function from the resolver. That way you have an easier way to work with it outside of parsing.

❤️ 1
Timofey Sitnikov 2021-06-21T02:24:42.227Z

OK, this helps, I was wondering why the functionality was broken out, specially in Fulcro RAD Demo, seemed like extra files, but now I understand.