This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-07
Channels
- # announcements (3)
- # babashka (28)
- # bangalore-clj (6)
- # beginners (91)
- # calva (14)
- # cider (7)
- # clojars (6)
- # clojure (24)
- # clojure-europe (3)
- # clojure-nl (5)
- # clojure-uk (134)
- # clojuredesign-podcast (1)
- # clojurescript (16)
- # cryogen (3)
- # cursive (3)
- # data-science (1)
- # events (1)
- # fulcro (7)
- # jobs-discuss (1)
- # luminus (4)
- # malli (1)
- # re-frame (7)
- # shadow-cljs (74)
- # spacemacs (23)
- # sql (6)
- # tools-deps (2)
All right: I’ve been threatening to show how to integrate Clara Rules with Fulcro for some time now, and I just did a demo that works pretty well in RAD, though RAD is by no means required. In fact, the way it works is really quite simple: • I add a watch to the state atom. When it triggers it saves off the current old state map (only if it has not done so since the last refresh), and schedules a rules run. • I use the old/new state map snapshots to figure out, for a list of Fulcro tables, which things have appeared/changed/disappeared • I convert the Fulcro db table entries that are “tracked” into Clara Fact records • I fire the rules • I run queries against the rules session to get the desired changes • I push those changes to the Fulcro DB.
https://github.com/fulcrologic/fulcro-rad-demo/blob/rules-demo/src/shared/com/example/rules.cljc
The rest is app-specific. This particular demo is for an invoice, where there is a calculated subtotal.