fix event metadata marker

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
Bruce Hauman 2018-10-18 09:59:55 -04:00 committed by Julien Eluard
parent 8b612900ef
commit 45e4671ce2
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
4 changed files with 10 additions and 7 deletions

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ website/static/js/
website/static/extensions/ website/static/extensions/
\.\#* \.\#*
.nrepl-port .nrepl-port
*.lck

View File

@ -39,7 +39,7 @@
(cond (contains? values o) (get values o) (cond (contains? values o) (get values o)
(symbol? o) nil (symbol? o) nil
(string? o) (utils/interpolate values o) (string? o) (utils/interpolate values o)
(and (fn? o) (= :event (meta o))) #(o % values) ;; Intercept events and inject the env. TODO remove this hack (and (fn? o) (:event (meta o))) #(o % values) ;; Intercept events and inject the env. TODO remove this hack
:else o)) :else o))
(defn walkup-upto-leaf [f lp? lf tree] (defn walkup-upto-leaf [f lp? lf tree]

View File

@ -116,11 +116,13 @@
:else o)) :else o))
(defn event-after-env [ref data args bindings] (defn event-after-env [ref data args bindings]
(with-meta
(fn [o env] (fn [o env]
(let [env (merge env (reduce-kv #(assoc %1 (symbol (name %2)) %3) {} o) (let [env (merge env (reduce-kv #(assoc %1 (symbol (name %2)) %3) {} o)
(:data (destructuring/destructure bindings (merge o args)))) (:data (destructuring/destructure bindings (merge o args))))
dic (reduce-kv #(assoc %1 %2 (if (contains? env %3) (get env %3) %3)) {} env)] dic (reduce-kv #(assoc %1 %2 (if (contains? env %3) (get env %3) %3)) {} env)]
[ref (merge o (reduce-kv #(assoc %1 %2 (replace-atom dic %3)) {} data))]))) [ref (merge o (reduce-kv #(assoc %1 %2 (replace-atom dic %3)) {} data))]))
{:event true}))
(defn- reference-with-arguments [ctx ext ref event arguments args bindings] (defn- reference-with-arguments [ctx ext ref event arguments args bindings]
(if arguments (if arguments

View File

@ -53,7 +53,7 @@
(defn wrap-data [type data env o] (defn wrap-data [type data env o]
(if (types/reference-types type) (if (types/reference-types type)
(if (= :event type) (if (= :event type)
(with-meta (fn [env o] (data env o)) :event) (with-meta (fn [env o] (data env o)) {:event true})
data) data)
data)) data))