Fork me on GitHub
eccentric J16:04:08

Hi, I was curious if fulcro supports event sourcing in a way kind of like re-frame does? I don’t know too much about it but in my mind event sourcing should play nicely with the graph concepts that may power fulcro.


@jayzawrotny could you elaborate on what you mean exactly?

eccentric J17:04:52

Sorry if the question is unclear, these are somewhat new subjects for me. I like modeling my frontends as state that receives updates like {:action "submit-signup-form" :data {:email "" :agree-to-tos true}} so that the front-end UI is only concerned with emitting intentions, then there’s something that acts upon that action and updates the app state and executes the required side effects to submit it to the backend.

eccentric J17:04:51

Is that something that can be setup with fulcro or am I completely misunderstanding it? What I like about that approach is that we get a natural log of meaningful actions that make up our business logic.


@jayzawrotny in fulcro you update the state via mutations, in some sense mutations could be considered the action name, due to quoting its usualy the namespace+name


Need to read that :) fulcro does not really get in your way, it helps out with app state( normalization, query colocated on components, etc) but you kinda have a lot of room to do as you want with a lot of optin utiities available that integrate really nicely in the overall picture.


I see it like this - whether or not you use event sourcing is really more of a backend concern, so orthogonal to what Fulcro or even Reframe are concerned about. However, a prerequisite for event sourcing is CQRS, which is fully embraced by Fulcro. I prefer to use Datomic on the backend, which although it’s not exactly event sourcing, kind of gives you the best of both worlds. The transaction log can serve as your record of events, especially if you annotate transactions with additional info such as the name of the event that triggered the transaction. At the same time, you can also query against the current DB, which you can view as a materialized view of the event stream. So yes, I think Fulcro is very compatible with event sourcing. That being said, I’ve heard just as many horror stories as success stories when using event sourcing in the large. But I think the Datomic approach gives you a lot of the same benefits without the pitfalls, so it’s a nice “happy medium”.

eccentric J20:04:13

By chance do you have any links to the event sourcing failures? I definitely want to learn the trade-offs.

eccentric J20:04:10

I suppose re-frame is not full event sourcing, but I do like being able to model front-end with plain action objects that we can log and update state but it sounds that something like that is definitely achievable with Fullcro.

eccentric J20:04:46

Also, this article made datomic feel like a good choice for simple event sourcing as you suggested


@jayzawrotny if you try out fulcro-inspect its mostly there. Mutation (action name) + data and state change. If you wont logging might find the support viewer interesting

eccentric J20:04:17

Interesting, thanks


This article points out some of the challenges/trade offs with event sourcing.

eccentric J20:04:51

You’re right @U3LP7DWPR the fulcro-inspect is probably close enough, especially with the support viewer.


For me, the biggest concerns are eventual consistency (maybe I’m old school, but I’ve always been skeptical of eventually consistent systems) and how difficult it is to make changes, especially once you are in production. If you have a production event sourced system running and need to make significant changes to your data model, you’re in for a world of hurt. And once you experience that, the mindset becomes that you have to “get it right” up front, so goodbye agility. Just my 2 cents.

👍 8

I am running into an issue with dynamic routing: I have a router

Router -> SubRouter
And the subrouter route target points to -> [:entity/id 1] the component is called Details And somewhere in the Router is a list of elements of which Also one points to -> [:entity/id 1] the component is called Entity When I want to change the route of the subrouter it tries to call the will-leave method of Entity which it doesn't have since it is not a route target


@U060GQK8U it’s kind of hard to help without more context, how exactly are you changing the route? a small github gist that reproduces your issue would be very helpful


IMO it’s best to make small examples that reproduce your undesired behavior in a workspace or devcard, and often times in the process of isolating this to a gist you figure out the cause


here’s an example workspace using dynamic router


you could use that as a starting point for building your case


(apologies if you already know about workspaces and stuff already, just trying to be helpful)


Thank you, no problem (we do use workspaces) 😉, I currently don't have time to make a reproduction, that is why I dropped it here like this. Maybe it is intentional or it is a bug


ok, unfortunately it’s impossible (for me) to help without more context


Ofcourse I get it


How would I convert the user-database in the template to be stored in the browser's memory instead?


by browser’s memory do you mean the browser’s localStorage?


also by user-database do you mean fulcro’s app-state? (the thing you see in the inspector’s DB tab)


for that you can use transit-clj->str to encode your app state as a string, then use the JS localStorage API to store/retrieve it, then use transit-str->clj to parse the encoding back into CLJS datastructures


also keep in mind, you app state will have to be serializable (can’t store callbacks or anything non-serializable)


but you should always be doing that regardless


does that make sense?


Hey, I was thinking just in RAM but localStorage would be good. The template just has the user-database in an atom and I wanted to replicate that but I got some help too in #pathom and I think I have a better understanding now 👍


While I develop I think it's easier to have it reset on page refresh then for production use localStorage/IndexedDB

Lauri Rutanen20:04:31

Hello, I have trouble running the Fulcro leiningen template (ie. created via 'lein new fulcro my-app'. When I run 'lein repl' on the project root, I get `clojure.lang.ExceptionInfo: Could not find clojure executable {:tried-paths ["/usr/local/bin/clojure"]}`


@UHJ0SKF7W i just created a new template and lein repl worked as expected


note that the template creates a deps.edn project, rather than a standard lein project


do you have the clojure CLI installed? i believe it’s part of the recent clojure releases


oh! also if you look at the README, you’re not even supposed to use lein repl


use clj -A:dev -J-Dtrace to launch the server repl


the README explains the whole dev setup

Lauri Rutanen17:04:13

@U09FEH8GN I was following the guide here: and it mentions this: "You can get a basic working app using: $ lein new fulcro app"


@UHJ0SKF7W oh i see, looks like that’s out of date…

Lauri Rutanen17:04:11

Ah indeed, I read the README. Sorry about that


thanks for noticing simple_smile


the book needs to be updated


i’ll do that in a bit

Lauri Rutanen17:04:05

About clojure CLI. didn't realise it was necessary as I have always depended on tools such as lein or mvn on this. But I'll install clojure cli tools as described here:


yeah it’s recent addition, meant to be used in conjunction with tools like boot and lein


at first i was skeptical, but it’s actually really cool


you can use it to point dependencies at local/remote git repos, which is pretty useful when developing libraries


i just submitted a PR to update the book


FYI the book is just ascii doc file in the fulcro repo, so feel free to submit PRs if you find anything else wrong simple_smile

👍 4