Fork me on GitHub
#fulcro
<
2018-11-04
>
tony.kay07:11:42

OK, so I’m very excited about this one: I’ve been mulling over state machines as a good addition to Fulcro for some time. There are many cases of user interface interaction where a good state machine would just be super handy, but I’ve never had the time to implement my ideas. Well, the time has arrived, and I think the result is pretty darn cool so far. My first experiments are very encouraging, and Fulcro lends itself very well to this kind of integration (via an add-on library). There’s nothing at all that needs to be changed/added about Fulcro, really…it’s already pretty much a giant state machine…app state is the state, though, and it’s up to you to organize it all, write mutations (your events and state manipulations), etc. The scheme I’ve come up with will go through a few more refinements, but it’s already quite capable, and I’ve got a login for demo that shows the promise. I’ve thrown it up in incubator, along with docs so you can follow along…I’ve defined a few concepts that make it much easier to write the state machine itself, and not have to talk anything about idents, etc. Have a look-see. It’s on a branch right now, but there is a workspace demo that is runnable: Docs: https://github.com/fulcrologic/fulcro-incubator/blob/master/state-machine-docs.adoc Workspace Demo (covered in docs): https://github.com/fulcrologic/fulcro-incubator/blob/master/src/workspaces/fulcro/incubator/state_machine_ws.cljs

🎉 32
👀 4
wilkerlucio17:11:28

@tony.kay the links seem to got broken, maybe the branch?

tony.kay17:11:01

ooops, really?

tony.kay17:11:16

yeah, branch 😜

tony.kay17:11:01

Fixed. Thanks!

tony.kay07:11:43

Oh, and I didn’t mention it in the docs, but it automatically figures out how to refresh the UI, so no follow-on reads are necessary 🙂

tony.kay07:11:26

I also did a model for some routing ideas I’ve had (but don’t have time to develop) if anyone is interested in play with those: https://github.com/fulcrologic/fulcro-incubator/blob/feature/routing-experiment/src/workspaces/fulcro/incubator/routing_ws.cljs

metal 4
tony.kay07:11:52

The experimental routers stuff will compose…a really nice feature, and would allow bidi-like route interpretation to be built-in to the routers themselves…e.g. each router in a path “picks off” the elements of path that apply to it, and then try to pass the rest off to something “deeper” in the UI (by searching via the query)…so they don’t have to know anything about it…also lets you “query” the current route from UI state in the same manner…would also allow for refactoring of the app with “self healing” URI paths.

tony.kay07:11:14

would also work for code splitting

tony.kay07:11:41

anyway…I know a lot of ppl are interested in the UI routing/URI problem. I don’t have time to deal with that one, but for what it’s worth, there it is 🙂

claudiu13:11:28

@pvillegas12 yep :) on it. Writing docs now for the stuff I've got working

pvillegas1212:11:22

I would like to change the URL the fulcro app points to depending on the environment, how can I do this? From the book it is not clear how production configuration works

tony.kay18:11:56

you mean away from /api???

pvillegas1219:11:17

@tony.kay I’m currently overriding the remote url in order to target a different port. In production, though, I want it to point to the ion api gateway

pvillegas1219:11:41

so localhost:3000/api vs api-gateway-url/api

eoliphant19:11:47

@pvillegas12 you're using fulcro with Datomic ions? literally in the process of moving an app over, did you have any issues gettting it going?

pvillegas1219:11:02

I had no experience with clojure(script), aws or datomic, so that has been really the bottleneck 🙂 Apart from that, there have not been any hindrances. Once you get the big picture you change your architecture to satisfy that decision

pvillegas1219:11:52

eg. I separated the backend from frontend because of the ion direction

pvillegas1219:11:00

(I’m still not 100% if that is necessary though :))

eoliphant19:11:01

yeah i'm coming from the opposite direction lol Tons of AWS experience, been using ions since they have been available, and have deployed a few production services with them. etc etc. but just haven't smushed a fulcro server into an ion yet lol

pvillegas1219:11:32

I’m not using a fulcro server, instead I’m using a ring handler

eoliphant19:11:35

yeah i sort of like having a separate ui package

pvillegas1219:11:45

(well I am using fulcro server to process the queries / mutations)

eoliphant19:11:55

and pushing all the assets to cloudfront, etc

eoliphant19:11:59

but gonna start simple

pvillegas1219:11:00

yup, that’s my flow right now

pvillegas1219:11:16

if you stumble let me know 🙂

eoliphant19:11:31

right, i gathered that hte fulcro server stuff was ring compatible so dropping it into an APIGW enabled ion "should" be straightforward 🙂

eoliphant19:11:41

will do thanks 🙂

pvillegas1219:11:29

for now, it has not been problematic, you do need to wrangle some dependency errors but that’s about it

eoliphant19:11:47

yeah that's part of ion fun lol

pvillegas1219:11:49

(ion’s have certain versions of libraries that may conflict with your dependency set)

eoliphant19:11:02

they've wandered into applicaton server territory

eoliphant19:11:36

but don't really do the stuff that classic one's do with dedicated classloaders etc

eoliphant19:11:10

but haven't had too many problems, their spitting out all the conflicts is super helpful

pvillegas1219:11:45

@eoliphant are you also using datomic?

eoliphant19:11:04

we had a variety

eoliphant19:11:19

moving it all to cloud/ions

pvillegas1219:11:11

what do you use for migrations of schema for datomic cloud?

eoliphant19:11:53

nothing at the moment 😞 I've been looking at forking and hacking conformity

tony.kay19:11:48

@pvillegas12 You can use a compiler option to set variables, and then base your remote on that variable

tony.kay19:11:45

:closure-defines in compiler settings

pvillegas1219:11:18

(using shadow)

tony.kay19:11:43

shadow passes those through the the normal cljs compiler…as documented (some are controlled by shadow, but many are passed through)

eoliphant21:11:34

quick question using a 3rd part react mapping lib (react-map-gl). and need to convert this <ReactMapGL {...viewport} onViewportChange={updateViewport}> to the appropriate fulcro stuff, I tried something like this (ui-react-map-gl (prim/computed viewport {:onViewportChange #(prim/transact! this [(api/update-viewport {:viewport ~%})])})` but that's not quite doing it 🙂 I created (ui-react-map-gl) via the component factory stuff in the incubator