New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve event matching #8
Conversation
…e required-events vector
src/day8/re_frame/async_flow_fx.cljs
Outdated
@@ -8,7 +8,7 @@ | |||
"Dissociates an entry from a nested associative structure returning a new | |||
nested structure. keys is a sequence of keys. Any empty maps that result | |||
will not be present in the new structure. | |||
The key thing is that 'm' remains identical? to istelf if the path was never present" | |||
The key thing is that 'm' remains identical? to iself if the path was never present" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still misspelled comment iself
src/day8/re_frame/async_flow_fx.cljs
Outdated
will either | ||
- match only the event-keyword if a keyword is supplied | ||
- match the entire event vector if a collection is supplied | ||
- returns a the item itself if a fn is supplied" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returns callback-pred if it is a fn
src/day8/re_frame/async_flow_fx.cljs
Outdated
(defn seen-all-of? | ||
[required-events seen-events] | ||
(empty? (set/difference required-events seen-events))) | ||
(every? | ||
(fn [pred] (some (fn [e] (pred e)) seen-events)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can (some (fn [e] (pred e)) seen-events)
be written as (some pred seen-events)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think every-pred
might be better still here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
every-pred? sadly won't work as the preds are applied in the inner fn.
src/day8/re_frame/async_flow_fx.cljs
Outdated
|
||
|
||
(defn seen-any-of? | ||
[required-events seen-events] | ||
(some? (seq (set/intersection seen-events required-events)))) | ||
(some? (some | ||
(fn [pred] (some (fn [e] (pred e)) seen-events)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can (some (fn [e] (pred e)) seen-events)
be written as (some pred seen-events)
? Perhaps it would also be easier to read if it was extracted into a let binding as any-pred?
c7c6c7f
to
53bc6d1
Compare
Improve event matching by allowing event vectors and predicates in the required-events vector.
In day8 internal code some things that currently can't be handled by an async flow will be possible with these changes.
In this pr I attempt to address some of the comments in #6 but do it in a different way and do not cover all of the use cases.
In particular, the
event-id->seen-fn
is now handled by providing predicate fn's as used elsewhere in re-frame