Is this a bug in fulcro statecharts?
(transition {:cond (fn [_ data event-name event-data]
(println :cond :event-name event-name :event-data event-data))}
(script-fn [_ data event-name event-data]
(println :script :event-name event-name :event-data event-data)))
=> :cond nil nil
=> :script ok ok
I would have expected the event and event-data to also be available within the cond?(state {:id :state/closed}
(transition {:cond (fn [_ data])
:target [:state/lti-mode :state/lti-choosing-step]})
(transition {:event :event/open-modal
:cond (fn [_ _ _ event-data])
:target [:state/lti-mode :state/lti-choosing-step]})
(transition {:event :event/open-modal
:target [:state/regular-mode :state/name-step]}))
yeah I have to study this deeper, the first transition cond is actually only evaluated when the statechart starts and not anymore when the :event/open-modal is received so my solution now is to have a transition that explicitely has that event defined, even though it's a dev onyl thing because the first transition :cond is checking the url for paramsso when this behavior only occurs when there is no event key
IIRC on the cond it's available in :_event of data.
I don't have a test cond to tap from but you can put a tap into your cond there and see if data has :_event with that info.
No it's not, at least not when there is no :event in the transition
Ahh yeah that makes sense, misunderstood what you meant there. If there is no event then :_event won't be populated, since that only gets added from the event.
It could be a bug. The fact that the transition isn’t event-based (it is a default) is still going to happen in some context where some kind of event occurred (unless it is startup)…so on the surface I would expect the “current contextual event” to perhaps be available. I’m not sure if the W3C spec has anything to say about this case, but I also don’t really see the harm in it. Statecharts (and machines in general) can have additional things “happen”…e.g. a transition that is taken that causes another transition, etc. The whole thing eventually stabilizes. So, in the cases of the processing these “secondary” transitions there may be something in the spec that says the event isn’t there because an event didn’t cause it, but I don’t remember any such specification. It is probably just an oversight.
If you can find the section of the SCXML spec that covers this stuff, you could clarify how it MUST work, at which point we can determine if this is a bug. You could also look at the impl file and just try to put the event in context. I don’t see any reason for it to not be there unless it is startup and there was no event.
I wrote a test in statecharts. It is working as expected. See https://github.com/fulcrologic/statecharts/blob/2062e60ab71d67f0cf0c01d96392196ab032b39f/src/test/com/fulcrologic/statecharts/algorithms/v20150901/internal_transitions_spec.cljc#L91
I'm struggling with GraphQL integration in my Fulcro3/Pathom2 app and am in need of some advice. I'm querying against Github's API and have run into a road block with gql->eql syntax. Here is the gql query I'm trying to implement:
{
repository(owner: "owner", name: "name") {
object(expression: "main:") {
... on Tree {
id
entries {
oid
path
type
name
}
}
}
}
}
;; Here is my current ident-map
::pcg/ident-map
{"repository" {"owner" :github.repository/owner
"name" :github.repository/name}
"object" {"expression" :github.object/expression}}
Dynamic indexing is working fine for 'repository' and 'object' and I'm able to return data, but I'm stuck on the '... on Tree' line. I'm not sure how to properly translate this. Anybody have any ideas? Thanks in advance!