Skip to content

Commit

Permalink
Fixed arity problems on macro helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
awkay committed Nov 10, 2024
1 parent 55478ac commit 0395620
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions src/main/com/fulcrologic/statecharts/elements.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@
```
"
[[env-sym data-sym] & body]
[arglist & body]
`(on-exit {:diagram/label ~(expr-label body)}
(script {:expr (fn [~env-sym ~data-sym]
~@body)})))
(script {:expr (fn ~arglist ~@body)})))

(defmacro entry-fn
"A macro that emits a `on-entry` element, but looks more like a normal CLJC lambda:
Expand All @@ -159,10 +158,9 @@
```
"
[[env-sym data-sym] & body]
[arglist & body]
`(on-entry {:diagram/label ~(expr-label body)}
(script {:expr (fn [~env-sym ~data-sym]
~@body)})))
(script {:expr (fn ~arglist ~@body)})))


(defn history
Expand Down Expand Up @@ -263,11 +261,11 @@
(script {:expr (fn [env data] ...)})
```
You can include the number of args that your execution env expects.
"
[[env-sym data-sym] & body]
[arglist & body]
`(script {:diagram/label ~(expr-label body)
:expr (fn [~env-sym ~data-sym]
~@body)}))
:expr (fn ~arglist ~@body)}))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; External Communication
Expand Down
6 changes: 3 additions & 3 deletions src/main/com/fulcrologic/statecharts/integration/fulcro.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
a final state.
Returns the new session-id of the statechart."
[app {:keys [machine session-id data]
[app-ish {:keys [machine session-id data]
:or {session-id (new-uuid)
data {}}}]
[::fulcro-appish [:map
Expand All @@ -197,8 +197,8 @@
[:data {:optional true} map?]] => (? ::sc/session-id)]
(when machine
(let [env (or
(statechart-env app)
(throw (ex-info "Statecharts are not installed on that app." {})))
(statechart-env app-ish)
(throw (ex-info "Statecharts are not installed." {})))
{::sc/keys [processor working-memory-store]} env
s0 (sp/start! processor env machine (cond-> {::sc/session-id session-id
:org.w3.scxml.event/invokeid (new-uuid)
Expand Down

0 comments on commit 0395620

Please sign in to comment.