This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-02
Channels
- # announcements (2)
- # beginners (32)
- # boot (10)
- # calva (81)
- # cider (39)
- # clojure (56)
- # clojure-europe (8)
- # clojure-italy (7)
- # clojure-new-zealand (1)
- # clojure-nl (8)
- # clojure-poland (1)
- # clojure-spec (12)
- # clojure-uk (38)
- # clojurescript (5)
- # community-development (1)
- # core-async (55)
- # cursive (3)
- # datomic (44)
- # dirac (15)
- # emacs (20)
- # events (1)
- # fulcro (57)
- # hyperfiddle (2)
- # jobs (9)
- # juxt (9)
- # kaocha (1)
- # lein-figwheel (1)
- # off-topic (93)
- # pathom (2)
- # pedestal (3)
- # planck (3)
- # reitit (15)
- # ring (10)
- # shadow-cljs (25)
- # spacemacs (7)
- # sql (19)
- # tools-deps (8)
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?
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 "
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.
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 http://book.fulcrologic.com/#Mutations
I found this which while aimed at GraphQL, may be applied to Fulcro https://medium.com/@marcusstenbeck/show-calendar-part-1-setting-up-the-api-89c4b55234df
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”.
By chance do you have any links to the event sourcing failures? I definitely want to learn the trade-offs.
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.
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
@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
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
You’re right @U3LP7DWPR the fulcro-inspect is probably close enough, especially with the support viewer.
Thanks @U0JPBB10W
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.
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
those functions can be found in https://github.com/fulcrologic/fulcro/blob/develop/src/main/fulcro/client/util.cljc#L44
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
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
@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"
@UHJ0SKF7W oh i see, looks like that’s out of date…
Ah indeed, I read the README. Sorry about that
thanks for noticing
the book needs to be updated
i’ll do that in a bit
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
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