Fork me on GitHub
#fulcro
<
2019-04-02
>
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.

hmaurer17:04:51

@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.

claudiu19:04:58

@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 http://book.fulcrologic.com/#Mutations

claudiu20:04:31

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.

mdhaney20:04:15

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 https://vvvvalvalval.github.io/posts/2018-11-12-datomic-event-sourcing-without-the-hassle.html

claudiu20:04:44

@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 http://book.fulcrologic.com/#_support_viewer

eccentric J20:04:17

Interesting, thanks

mdhaney20:04:49

This article points out some of the challenges/trade offs with event sourcing. https://medium.com/@hugo.oliveira.rocha/what-they-dont-tell-you-about-event-sourcing-6afc23c69e9a

eccentric J20:04:51

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

mdhaney20:04:46

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
mitchelkuijpers17:04:34

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

currentoor20:04:58

@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

currentoor20:04:26

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

currentoor20:04:00

here’s an example workspace using dynamic router

currentoor20:04:52

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

currentoor20:04:20

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

mitchelkuijpers20:04:25

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

currentoor23:04:51

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

mitchelkuijpers00:04:11

Ofcourse I get it

lauritzsh19:04:31

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

currentoor20:04:03

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

currentoor20:04:36

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

currentoor20:04:50

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

currentoor20:04:40

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

currentoor20:04:47

but you should always be doing that regardless

currentoor20:04:52

does that make sense?

lauritzsh12:04:55

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 👍

lauritzsh12:04:42

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"]}`

currentoor21:04:41

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

currentoor21:04:26

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

currentoor21:04:35

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

currentoor21:04:36

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

currentoor21:04:48

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

currentoor21:04:10

the README explains the whole dev setup

Lauri Rutanen17:04:13

@U09FEH8GN I was following the guide here: http://book.fulcrologic.com/#_project_setup and it mentions this: "You can get a basic working app using: $ lein new fulcro app"

currentoor17:04:08

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

Lauri Rutanen17:04:11

Ah indeed, I read the README. Sorry about that

currentoor17:04:15

thanks for noticing simple_smile

currentoor17:04:46

the book needs to be updated

currentoor17:04:52

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: https://clojure.org/guides/getting_started#_clojure_installer_and_cli_tools

currentoor17:04:01

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

currentoor17:04:23

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

currentoor17:04:58

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

currentoor17:04:35

i just submitted a PR to update the book

currentoor17:04:14

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