Skip to content

Instantly share code, notes, and snippets.

Avatar
💓
Loving Clojure

Jakub Holy holyjak

💓
Loving Clojure
View GitHub Profile
@holyjak
holyjak / fulcr-ssr-test.clj
Created Jan 22, 2021
Experiments in Fulcro SSR with dynamic routers
View fulcr-ssr-test.clj
(ns ssr-test
"Try server-side rendering in Fulcro where we want to display a non-default
dynamic router target.
*BEWARE*: This is an exploration. I have *no* idea what is the correct way."
(:require
[com.fulcrologic.fulcro.application :as app]
[com.fulcrologic.fulcro.algorithms.denormalize :as denorm]
[com.fulcrologic.fulcro.algorithms.server-render :as ssr]
[com.fulcrologic.fulcro.components :as comp :refer [defsc]]
[com.fulcrologic.fulcro.dom-server :as dom :refer [div label input]]
@holyjak
holyjak / fulcro-rad-notes.md
Last active Jan 15, 2021
Fulcro RAD - assorted notes
View fulcro-rad-notes.md

Unsorted notes on Fulcro RAD.

Reports

Displaying to-one :ref attributes

If you have a :ref attribute, you typically do not want to display it directly, i.e. its ident, but a more display-friendly prop of the child entity. This is handled automatically for you by Pathom, you only need to specify the attribute you want.

Let's assume you have a Person entity with the ref attribute person/home-address with the target address/id. You can simply have ro/columns [person/name ... address/city address/country] (assuming these attributes are defined and have :address/id among their ao/identities). Pathom can navigate from person/home-address -> address/id -> address/city etc.

@holyjak
holyjak / Fulcro-router-wrong-target-issue.md
Last active Dec 15, 2020
Description of a problem with UI displaying one target, Router beliving it displays another one.
View Fulcro-router-wrong-target-issue.md

I am running into an issue with Fulcro 3.4 and RAD 1.0.8 where the UI shows the (non-default) router target in an uninitialized state while the router believes that it is displaying the default target. I still cannot figure out why.

I have three nested routers (along with some other components): RootRouter > OrgRouter > OrgDashboard for org id=nnn > DetailsDisplayRouter with :targets [LatestBillRunList SubscriberList] and the URL .../org/123/subscribers and I expect to see the SubscriberList RAD report - which I do, but it is empty, even though the DB has the data, because the parent router believes it is displaying the other report . This only happens when I go to the URL in the browser, not when I click myself through the app to the state.

So how is it possible that DetailsDisplayRouter believes it is displaying LatestBillRunList while it should, and the UI does, show SubscriberList?!

I understand why the report is empty despite the presence of its data - Fulcro believes it is not showi

@holyjak
holyjak / deps.edn
Last active Oct 30, 2020
cryogen deps
View deps.edn
;; Put this inside your blog and use the clojure CLI instead of leiningen to run `clojure -X:serve`
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
ring-server/ring-server {:mvn/version "0.5.0"}
ring/ring-devel {:mvn/version "1.7.1"}
compojure/compojure {:mvn/version "1.6.1"}
#_#_cryogen-core/cryogen-core {:mvn/version "0.3.2"}
cryogen-asciidoc/cryogen-asciidoc {:mvn/version "0.3.2"}
cryogen-flexmark/cryogen-flexmark {:mvn/version "0.1.4"}
cryogen-core/cryogen-core {:git/url "https://github.com/cryogen-project/cryogen-core" :sha "17cdf3837f17b9b921dce09e4638495984e65a2a"}
}
@holyjak
holyjak / troubleshooting 404 in Spring MVC.md
Created Oct 22, 2020
WIP - troubleshooting 404 in Spring MVC 4
View troubleshooting 404 in Spring MVC.md

Spring 4 - 404 troubleshooting

See https://www.baeldung.com/spring-handler-mappings - explains BeanNameUrlHandlerMapping, SimpleUrlHandlerMapping

Debug DispatcherServlet - DispatcherServlet.getHandler

@holyjak
holyjak / catching-transduce.clj
Created Jul 10, 2020
catching-transduce and a mysterious freeze
View catching-transduce.clj
;; catching-transduce - works most of the time but blocks forever in some case(s)
;; If I interrupt it, it is at line 26, i.e. inside `(a/<!! errors-ch)`
;; inside core.async ... CountDownLatch.await
(with-test
(defn catching-transduce
"Similar to `core.async/transduce` but returns the reduced value and
captures 'anomalies' (i.e. exceptions sent as data) in the `chan` data and
captures exceptions in `xf` and `f`, stopping at the first one.
Returns the result or throws if there was any anomaly / exception."
View Error handling in Fulcro: 3 approaches.adoc

Update: This has now been published at https://blog.jakubholy.net/2020/error-handling-in-fulcro/

I present three ways of detecting, handling, and showing server-side errors: globally and at the component level.

By default, Fulcro considers only non-200 HTTP status as an error. It is up to you to tell it what is an error and how to handle it.

This is somewhat controversial - as Programming with Pure Optimism in the Fulcro Developers Guide explains:

A server should not throw an exception and trigger a need for error handling unless there is a real, non-recoverable situation.

@holyjak
holyjak / Fulcr-x-Redux-talk.md
Last active Oct 14, 2020
Want more from your frontend framework!
View Fulcr-x-Redux-talk.md

Source code for my Telia Full Stack Feast talk "Want more from your frontend framework!" (slides) (6/2020), comparing Redux with REST and a Fulcro with Pathom (Graph API).

Use case we are implementing: Show “hot deals” in your webshop, loaded on-demand.

PS: For the sake of simplicity I am cheating a little and presenting the Fulcro HotDeals component as a root component. If it was used as a child, we would need to either change the a Link Query or make sure that the :deals are presented as a property on the parent component. Also, I use unqualified keys for brevity. This is not recommended in practice.

@holyjak
holyjak / Fulcro_Field_Notes.adoc
Last active Jan 6, 2021
Assorted notes from learning and experimenting with Fulcro [WIP]
View Fulcro_Field_Notes.adoc

Fulcro Field Notes

Assorted notes from learning and experimenting with Fulcro.

General

From Tony Kay:

[..] a guiding principle that always helps me: Rendering in Fulcro is a pure function of state. Get the state right, and rendering will follow.

@holyjak
holyjak / fulcro-rad-report-needs.md
Last active Mar 24, 2020
Fulcro-RAD report needs
View fulcro-rad-report-needs.md

I am making a PoC of an app with a number of linked "reports" (mostly master-detail). Some of the features I will need:

  • Ability to sort the tables by one or multiple columns
  • Ability to filter the tables (e.g. "only show people from Norway")
  • Pagination
  • Eventually allow the user to hide some columns (and remember this for the user, e.g. in a cookie / localStorage / server)

As far as I know, fulcro-rad does not support that yet so here are some thoughts about how this could be configured.