Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ pom.xml.asc
.hg/
*.log
.idea
*.iml
*.iml
.cpcache/
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ In broad strokes:

Query notification on updated facts is provided by the [RETE algorithm](https://en.wikipedia.org/wiki/Rete_algorithm), which is designed specifically to provide efficient activiation of rules in response to new facts. FactUI uses [Clara](http://www.clara-rules.org), an excellent RETE implementation for ClojureScript.

## Installation

Add the following to your `deps.edn`:

```
cjsauer/factui {:git/url "https://github.com/cjsauer/factui.git"
:sha "9222bdd2778c5413792d067b81f3506935e2cdaa"}
```

## Usage

Note: This section provides documentation using FactUI's integration with the [Rum](https://github.com/tonsky/rum) React wrapper. FactUI is not tightly coupled with Rum, it is entirely possible to build integration between FactUI and alternative wrappers (such as [Reagent](https://reagent-project.github.io) or [Om](https://github.com/omcljs/om) with relatively little effort. However, those have not yet been built.
Expand Down
16 changes: 16 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{:paths ["src"]

:deps {org.clojure/core.async {:mvn/version "0.3.443"}
com.cerner/clara-rules {:mvn/version "0.15.1" :exclusions [prismatic/schema]}
prismatic/schema {:mvn/version "1.1.6"}
org.clojure/core.match {:mvn/version "0.3.0-alpha4"}}

:aliases
{:clj {:extra-deps {;; Clojure(Script) is "provided"
org.clojure/clojure {:mvn/version "1.10.0"}
org.clojure/clojurescript {:mvn/version "1.10.520"}}}
:test {:extra-paths ["test" "target"]
:extra-deps {org.clojure/test.check {:mvn/version "RELEASE"}}}
:dev {:extra-paths ["dev" "target"]
:extra-deps {figwheel-sidecar {:mvn/version "0.5.12"}
rum {:mvn/version "0.10.8"}}}}}
25 changes: 11 additions & 14 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
(defproject org.arachne-framework/factui "1.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.9.0-alpha17" :scope "provided"]
[org.clojure/clojurescript "1.9.671" :scope "provided"]
[org.clojure/core.async "0.3.443"]
[com.cerner/clara-rules "0.15.1" :exclusions [prismatic/schema]]
[prismatic/schema "1.1.6"]
[org.clojure/core.match "0.3.0-alpha4"]]
:source-paths ["dev" "src"]
:profiles {:test {:plugins [[lein-shell "0.4.0" :exclusions [org.clojure/clojure]]

;; tools.deps
:plugins [[lein-tools-deps "0.4.5"]]
:middleware [lein-tools-deps.plugin/resolve-dependencies-with-deps-edn]
:lein-tools-deps/config {:config-files [:install :user :project]}

:profiles {:test {:lein-tools-deps/config {:aliases [:clj :test]}
:plugins [[lein-shell "0.4.0" :exclusions [org.clojure/clojure]]
[lein-cljsbuild "1.1.6" :exclusions [org.clojure/clojure]]]
:clean-targets ^{:protect false} ["target" :target-path]
:cljsbuild {:builds [{:id "dev-figwheel"
:source-paths ["src" "dev"]
:figwheel {:on-jsload "factui.rum/refresh"}
Expand Down Expand Up @@ -60,11 +61,7 @@
["cljsbuild" "once" "test-bench"]
["shell" "phantomjs" "target/test-bench.js"]]
}}
:dev {:plugins [[lein-figwheel "0.5.12" :exclusions [org.clojure/clojurescript]]]
:dependencies [[figwheel-sidecar "0.5.12"]
[rum "0.10.8"]]
:source-paths ["dev" "test"]
:resource-paths ["target"]
:dev {:lein-tools-deps/config {:aliases [:clj :dev]}
:plugins [[lein-figwheel "0.5.12" :exclusions [org.clojure/clojurescript]]]
:clean-targets ^{:protect false} ["target" :target-path]

:figwheel {:open-file-command "emacsclient"}}})
8 changes: 4 additions & 4 deletions src/factui/rum.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[factui.impl.store :as store])
(:require-macros [cljs.core.async.macros :refer [go-loop]]))

(def ^:private *rebuild-on-refresh* (atom true))
(def ^:private rebuild-on-refresh (atom true))

(defn set-rebuild-on-refresh
"Sets whether the session be should be entirely rebuilt on a new rulebase,
Expand All @@ -18,7 +18,7 @@
However, this operation may be expensive with very large sessions. If
refreshing takes too long, you may wish to disable this."
[rebuild?]
(reset! *rebuild-on-refresh* rebuild?))
(reset! rebuild-on-refresh rebuild?))

(defn- query-args
"Given a Rum state and a query, return a vectory of FactUI query args, based
Expand Down Expand Up @@ -144,7 +144,7 @@
(add-watch version :version-watch
(fn [_ _ _ version]
(let [old-session @@app-state-holder
new-session (if @*rebuild-on-refresh*
new-session (if @rebuild-on-refresh
(f/rebuild-session @rulebase old-session schema)
old-session)]
(reset! app-state-holder (atom new-session))
Expand Down Expand Up @@ -173,4 +173,4 @@
(let [txdata (if (map? txdata) [txdata])]
(fn [evt]
(.preventDefault evt)
(transact! app-state txdata))))
(transact! app-state txdata))))